醫學統計與R語言:Rare Events Logistic Regression

2021-02-26 醫學統計與R語言

微信公眾號:醫學統計與R語言

簡介

如果疾病的發生水平很低,極為不常見,病例在人群中所佔比再就非常小,那麼稱這個醫學事件為稀有事件。如果我們採用常見的現況流行病調查方法或隊列研究研究這種疾病,就會導致收集的數據中病例數與非病例數很不均衡。比如要探索研究該疾病的影響因素,通常的做法是對病例和非病例的兩類人群建立logistic回歸模型,然而由於資料中的病例所佔的比例遠遠低於非病例的比重,這就給稀有事件的統計分析帶來一系列問題,在這種情況下仍採用常規的logistic回歸方法就不適合了。

Example

論文:"Breast Cancer Risk Factors in a Defined Population: Weighted Logistic Regression Approach for Rare Events"中METHOD描述如下:

Statistical analysis was performed using statistical analysis software SPSS version 11.5 (SPSS Inc., Chicago, USA). Relogit (logistic regression model for rare events) analysis with a weighting method, which was performed using the program Zelig, was used to determine risk factors . In the univariate model, odds ratios [ORs] and confidence intervals [CIs] were calculated. Covariates with a p-value of less than 0.25 were included into the multiple relogit model to determine risk factors.

Syntax

- 輸入1:

install.packages("Hmisc")
library(Hmisc)
datalog <- spss.get("logistic.sav",to.data.frame=T)
library(psych)
headTail(datalog,5,5)

- 結果1:

     sex age diabetes tumour lbp pancreatitis die
1     1  10        0      1   0            0   1
2     1  12        0      0   1            0   1
3     2  12        0      0   0            1   1
4     2  14        1      0   1            0   1
5     1  15        1      0   0            0   1
... ... ...      ...    ... ...          ... ...
418   2  77        0      0   0            0   0
419   2  77        0      1   0            0   0
420   1  80        0      0   0            0   0
421   2  88        0      0   0            0   0
422   2  89        0      0   0            0   0 

- 輸入2:

table(datalog$die)

- 結果2:

 0   1 
402  20 

If you have a sample size of 1000 but only 20 events, you have a problem. If you have a sample size of 10,000 with 200 events, you may be OK. If your sample has 100,000 cases with 2000 events, you’re golden.There’s nothing wrong with the logistic model in such cases. The problem is that maximum likelihood estimation of the logistic model is well-known to suffer from small-sample bias. And the degree of bias is strongly dependent on the number of cases in the less frequent of the two categories. So even with a sample size of 100,000, if there are only 20 events in the sample, you may have substantial bias.

- 輸入3:

install.packages("Zelig")
library(Zelig)
zelig.out <- zelig(die~sex+age+diabetes+tumour+lbp+pancreatitis,data=datalog,model="relogit",tau=0.05)
summary(zelig.out)

預先校正法(prior correction),tau=0.05,為已知總體概率;
加權校正法(weight correction),在Zelig中增加case.control = "weighting"

- 結果3:

Model: 

Call:
z5$zelig(formula = die ~ sex + age + diabetes + tumour + lbp + 
    pancreatitis, tau = 0.05, data = datalog)

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-1.37037  -0.21257  -0.07337  -0.01692   2.63922  

Coefficients:
             Estimate Std. Error z value Pr(>|z|)
(Intercept)   0.30000    1.15233   0.260  0.79460
sex           0.01184    0.61486   0.019  0.98464
age          -0.16363    0.03832  -4.270 1.96e-05
diabetes      3.52070    1.22176   2.882  0.00396
tumour        2.36537    1.15653   2.045  0.04083
lbp           1.60375    0.66204   2.422  0.01542
pancreatitis  1.51434    0.85844   1.764  0.07772

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 161.008  on 421  degrees of freedom
Residual deviance:  80.129  on 415  degrees of freedom
AIC: 94.129

Number of Fisher Scoring iterations: 8

Next step: Use 'setx' method

相關焦點

  • 醫學統計與R語言:Kendall是誰?樣本量是自變量的10倍?
    醫學統計與R語言:一份簡單的數據整理分析醫學統計與R語言:利用金字塔圖比較多個指標醫學統計與R語言:點圖(dotplot)醫學統計與R語言:幕後高手出馬!Linear fix effect model )醫學統計與R語言:Tobit回歸模型函數醫學統計與R語言:隨機森林與Logistic預測(randomForest vs Logistic regression)醫學統計與R語言:多重比較P值的可視化醫學統計與R語言:腫瘤研究中的waterfall plot(瀑布圖)
  • 醫學統計與R語言:GiViTI Calibration Belt
    A new test and graphical tool to assess the goodness of fit of logistic regression models. Statistics in medicine, 35(5), 709-720.
  • logistic回歸Hosmer-Lemeshow擬合優度檢驗
    > 在建立預測模型的時候通常會報告一個擬合優度檢驗的結果(FrankHarrell指出這個指標存在一些缺點),今天結合R語言簡要介紹
  • r語言的p值檢驗 - CSDN
    輸入1: rdata = matrix(rnorm(1000* 6, 0, 3), 6) rvar = apply(rdata, 2, var) mean(rvar)結果1: 醫學統計與R語言:對數正態分布與卡方分布醫學統計與R語言:qvalue醫學統計與R語言:Meta 回歸作圖(Meta regression Plot)醫學統計與R語言:aggregate.plot了解一下醫學統計與R語言:有序Probit回歸(Ordered Probit Model)醫學統計與R語言:Probit回歸模型及邊際效應
  • 醫學統計與R語言:Cronbach's α Coefficient
    微信公眾號:醫學統計與R語言簡介Cronbach's alpha  is a function
  • 醫學統計與R語言:Meta 回歸作圖(Meta regression Plot)
    微信公眾號:醫學統計與R語言如果你覺得對你有幫助,歡迎轉發輸入1:  install.packages("metafor") library(metafor) dat.bcg結果1:    trial               author year
  • 一文詳述:觀察性研究中的logistic回歸分析思路
    本文內容來自《中華流行病學雜誌》2019年第40卷第8期,作者為馮國雙教授,原題目為《觀察性研究中的logistic回歸分析思路》。將這篇文章分享給醫咖會的夥伴們,希望大家能從領域大咖的見解中有所收穫,指導醫學研究之路。
  • 零基礎的同學如何用Stata做logistic回歸?
    同學們在做統計研究時,時常聽到身邊的朋友會提及一個詞:logistic回歸。聽的次數久了,同學們多半會思考:什麼是logistic回歸?如何在Stata中做logistic回歸呢?什麼是logistic回歸什麼是logistic回歸?
  • 多元回歸分析(multiple linear regression)和判別分析(discriminant analysis)
    大家在臨床科研的過程中經常會遇到一些需要研究多種因素之間關係的情況,這時候就要用到多因素分析的統計方法。
  • 用R進行Lasso regression回歸分析
    glmnet是由史丹福大學的統計學家們開發的一款R包,用於在傳統的廣義線性回歸模型的基礎上添加正則項,以有效解決過擬合的問題,支持線性回歸,邏輯回歸,泊松回歸,cox回歸等多種回歸模型,連結如下https://cran.r-project.org/web/packages/glmnet/index.html對於正則化,提供了以下3種正則化的方式
  • R語言從入門到精通:Day12--R語言統計--回歸分析
    回歸作為一個廣義的概念,涵蓋了許多變種,R語言中也為其提供了強大而豐富的函數和選項(但顯然選項越多,對初學者越不友好),早在2005年,R中就有200多種關於回歸分析的函數 (https://cran.r-project.org/doc/contrib/Ricci-refcard-regression.pdf,這個文檔提供了部分回歸分析函數列表,供大家參考)。
  • 從頭開始:用Python實現帶隨機梯度下降的Logistic回歸
    logistic 回歸算法logistic 回歸算法以該方法的核心函數命名,即 logistic 函數。logistic 回歸的表達式為方程,非常像線性回歸。輸入值(X)通過線性地組合權重或係數值來預測輸出值(y)。與線性回歸的主要區別在於,模型的輸出值是二值(0 或 1),而不是連續的數值。
  • r語言 做wald檢驗_r語言wald檢驗怎麼做 - CSDN
    用R語言遇到的一些問題。經常看到rcs()函數,比如擬合回歸時:f <- cph(S ~ rcs(age,4) + sex, x=T, y=T)。
  • SPSS統計分析案例:多項logistic回歸分析
    小兵博客幾年前分享的二項logistic回歸分析案例非常受歡迎,在實際應用中,可能還會碰到因變量是多個分類的情況,並且不包含排序信息。比如視力分為輕度、中度、重度三個水平,此時如果想考察影響視力評價的指標,常用的二項logistic回歸已經無法勝任。幸好,SPSS軟體為我們提供了多項logistic回歸。
  • Logistic回歸—初步了解10個問題
    1)對參數估計的影響,可能會把對模型有顯著影響的自變量排除在外; 回歸係數不穩定,解釋問題時往往會得出荒謬的結論,不能給予合理的醫學方面的解釋。同時,多重共線性常常會增大logistic 回歸模型估計參數的均方誤差和標準誤。變大的方差容易使區間預測值變寬,使預測失去意義。
  • 醫學統計與R語言:雙因素重複測量方差分析(Two-way repeated measures ANOVA)
    微信公眾號:醫學統計與R語言如果你覺得對你有幫助,歡迎轉發輸入1: setwd("C:\\Users\\mooshaa\\Desktop")rma <- read.csv("rma.csv",header=T)rma$group <- factor(rma$group
  • 掌握R語言for循環一文就夠了(認真臉)
    R語言相信大家在利用R語言進行數據分析的時候可能會有大數據分析需求。比如醫學數據,數據量大,維度極高,因為醫學的檢測指標多,而且隨著基因測序特別是二代測序等高通量測序(High-throughput sequencing)技術的普及,能一次測上萬的基因,這樣就有幾萬的維度;各種真實世界的統計數據,這些數據比如汽車損耗、公司盈虧也有著大樣本的特點。
  • R語言 小wald檢驗_lm檢驗 wald檢驗 - CSDN
    用R語言遇到的一些問題。經常看到rcs()函數,比如擬合回歸時:f <- cph(S ~ rcs(age,4) + sex, x=T, y=T)。
  • 【R語言教程】線性回歸決定係數R方的計算方法及具體意義 ——【醫學和生物統計】
    表達式:R2=SSR/SST=1-SSE/SST其中:SST=SSR+SSE,SST(total sum of squares)為總平方和,SSR(regression sum of squares)為回歸平方和,SSE(error sum of squares) 為殘差平方和。