纵向数据的分析方法之 广义估计方程

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

广义估计方程和混合效应模型及多水平模型的区别如下

  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.

#建立模拟数据集
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)
数据集情况
#查看病人个数(每个病人可以有多个观测)
dat%>%
  distinct(id)%>%
  count()
总共340例患者
#查看数据分布情况
with(dat, tapply(depression, list(diagnose, drug, time), mean)) %>% 
  ftable() %>% 
  round(2)
分组结果数据分布情况
#构建广义估计方程并查看最终结果
dep_gee <- gee(depression ~ diagnose + drug*time,#方程,注意交互作用
               data = dat, #数据集
               id = id, #患者识别编号
               family = binomial,#连接函数
               corstr = "independence")#数据相关矩阵,这里设定为独立
summary(dep_gee)
广义估计方程结果

exp(estimate)后可以得到OR值,可以看到,independence的作业相关矩阵中假设组内相关性是0,因为一个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".
#设定相关性矩阵为exchangeable,意思是组内配对之间的相关性系数相等
dep_gee2 <- gee(depression ~ diagnose + drug*time,
                data = dat, 
                id = id, 
                family = binomial,
                corstr = "exchangeable")
summary(dep_gee2)
exchangeable相关性矩阵下,除对角线外,其他相关性系数相等.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.
#设定自回归相关性矩阵并查看结果
dep_gee3 <- gee(depression ~ diagnose + drug*time,
                data = dat, 
                id = id, 
                family = binomial,
                corstr = "AR-M", Mv = 1)

dep_gee3$working.correlation
自回归矩阵,距离较近的点的相关性系数大于距离远的点

作业相关矩阵的选择

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.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
禁止转载,如需转载请通过简信或评论联系作者。

推荐阅读更多精彩内容

  • 好久没有更新文章了,因为同学们咨询的问题有点多,另一个原因就是自己实在太懒。。。。 今天继续给大家写广义估计方程式...
    Codewar阅读 9,299评论 4 6
  • 前言 Google Play应用市场对于应用的targetSdkVersion有了更为严格的要求。从 2018 年...
    申国骏阅读 64,714评论 15 98
  • 《来,我们说说孤独》 1·他们都在写孤独 一个诗人 如果 不说说 内心的孤独 不将孤独 写进诗里 是不是很掉价呢 ...
    听太阳升起阅读 4,403评论 1 7
  • 自幼贫民窟长大的女子,侥幸多念了两本书,枉以为可以与人平起平坐。可是人生从来都是接力赛,我们却天真的当成了百米冲刺...
    Leeanran阅读 5,792评论 1 5
  • 云舒老师,姓甚名谁,男的女的,多大岁数,这些我全然不知。之所以要写写云舒老师,完全是因为他写的文章,如一个巨大的磁...
    数豆者m阅读 2,399评论 6 9