縱向數(shù)據(jù)的分析方法之 廣義估計方程

英文教程地址
https://data.library.virginia.edu/getting-started-with-generalized-estimating-equations/

廣義估計方程和混合效應(yīng)模型及多水平模型的區(qū)別如下

  1. The main difference is that it’s a marginal model. It seeks to model a population average. Mixed-effect/Multilevel models are subject-specific, or conditional, models. They allow us to estimate different parameters for each subject or cluster. In other words, the parameter estimates are conditional on the subject/cluster. This in turn provides insight into the variability between subjects or clusters. We can also obtain a population-level model from a mixed-effect model, but it’s basically an average of the subject-specific models.

  2. GEE is intended for simple clustering or repeated measures. It cannot easily accommodate more complex designs such as nested or crossed groups; for example, nested repeated measures within a subject or group. This is something better suited for a mixed-effect model.

  3. GEE computations are usually easier than mixed-effect model computations. GEE does not use the likelihood methods that mixed-effect models employ, which means GEE can sometimes estimate more complex models.Because GEE doesn’t use likelihood methods, the estimated “model” is incomplete and not suitable for simulation.

  4. GEE allows us to specify a correlation structure for different responses within a subject or group. For example, we can specify that the correlation of measurements taken closer together is higher than those taken farther apart. This is not something that’s currently possible in the popular lme4 package.

#建立模擬數(shù)據(jù)集
URL <- "http://static.lib.virginia.edu/statlab/materials/data/depression.csv"
dat <- read.csv(URL, stringsAsFactors = TRUE)
dat$id <- factor(dat$id)
dat$drug <- relevel(dat$drug, ref = "standard")
head(dat, n = 3)
數(shù)據(jù)集情況
#查看病人個數(shù)(每個病人可以有多個觀測)
dat%>%
  distinct(id)%>%
  count()
總共340例患者
#查看數(shù)據(jù)分布情況
with(dat, tapply(depression, list(diagnose, drug, time), mean)) %>% 
  ftable() %>% 
  round(2)
分組結(jié)果數(shù)據(jù)分布情況
#構(gòu)建廣義估計方程并查看最終結(jié)果
dep_gee <- gee(depression ~ diagnose + drug*time,#方程,注意交互作用
               data = dat, #數(shù)據(jù)集
               id = id, #患者識別編號
               family = binomial,#連接函數(shù)
               corstr = "independence")#數(shù)據(jù)相關(guān)矩陣,這里設(shè)定為獨(dú)立
summary(dep_gee)
廣義估計方程結(jié)果

exp(estimate)后可以得到OR值,可以看到,independence的作業(yè)相關(guān)矩陣中假設(shè)組內(nèi)相關(guān)性是0,因?yàn)橐粋€id是3個觀察,所以是3乘以3的矩陣了

# Now let’s try a model with an exchangeable correlation structure. 
# This says all pairs of responses within a subject are equally correlated. 
# To do this we set corstr = "exchangeable".
#設(shè)定相關(guān)性矩陣為exchangeable,意思是組內(nèi)配對之間的相關(guān)性系數(shù)相等
dep_gee2 <- gee(depression ~ diagnose + drug*time,
                data = dat, 
                id = id, 
                family = binomial,
                corstr = "exchangeable")
summary(dep_gee2)
exchangeable相關(guān)性矩陣下,除對角線外,其他相關(guān)性系數(shù)相等.png
# Another possibility for correlation is an autoregressive structure. 
# This allows correlations of measurements taken closer together to be higher than those taken farther apart.
#設(shè)定自回歸相關(guān)性矩陣并查看結(jié)果
dep_gee3 <- gee(depression ~ diagnose + drug*time,
                data = dat, 
                id = id, 
                family = binomial,
                corstr = "AR-M", Mv = 1)

dep_gee3$working.correlation
自回歸矩陣,距離較近的點(diǎn)的相關(guān)性系數(shù)大于距離遠(yuǎn)的點(diǎn)

作業(yè)相關(guān)矩陣的選擇

How to choose which correlation structure to use? The good news is GEE estimates are valid even if you misspecify the correlation structure (Agresti, 2002). Of course this assumes the model is correct, but then again no model is exactly correct. Agresti suggests using the exchangeable structure as a start and then checking how the coefficient estimates and standard errors change with other correlation structures. If the changes are minimal, go with the simpler correlation structure.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
禁止轉(zhuǎn)載,如需轉(zhuǎn)載請通過簡信或評論聯(lián)系作者。

相關(guān)閱讀更多精彩內(nèi)容

  • 好久沒有更新文章了,因?yàn)橥瑢W(xué)們咨詢的問題有點(diǎn)多,另一個原因就是自己實(shí)在太懶。。。。 今天繼續(xù)給大家寫廣義估計方程式...
    Codewar閱讀 10,034評論 4 6
  • 前言 Google Play應(yīng)用市場對于應(yīng)用的targetSdkVersion有了更為嚴(yán)格的要求。從 2018 年...
    申國駿閱讀 65,722評論 15 98
  • 《來,我們說說孤獨(dú)》 1·他們都在寫孤獨(dú) 一個詩人 如果 不說說 內(nèi)心的孤獨(dú) 不將孤獨(dú) 寫進(jìn)詩里 是不是很掉價呢 ...
    聽太陽升起閱讀 4,585評論 1 7
  • 自幼貧民窟長大的女子,僥幸多念了兩本書,枉以為可以與人平起平坐。可是人生從來都是接力賽,我們卻天真的當(dāng)成了百米沖刺...
    Leeanran閱讀 5,901評論 1 5
  • 云舒老師,姓甚名誰,男的女的,多大歲數(shù),這些我全然不知。之所以要寫寫云舒老師,完全是因?yàn)樗麑懙奈恼?,如一個巨大的磁...
    數(shù)豆者m閱讀 2,535評論 6 9

友情鏈接更多精彩內(nèi)容