如何在二项混合效应模型或GEE

时间:2017-06-08 18:09:25

标签: r

我正在考虑指定与数据框(不是analytical weights)中的每个数据点相关联的逆概率权重,以用于混合效果逻辑回归,以用于与动物的可用GPS位置。我的问题与这篇文章密切相关:( Inverse probability weights in r),但对于混合效应模型。 svyglm函数指定正确的权重,但调查包不允许随机效果,lme4使用分析权重。我查看了coxme包作为替代,但帮助文件表明权重是按照lm指定的,它使用分析权重。

是否在r中实现了一个包/函数来指定混合效果的采样权重,还是使用coxme包指定采样权重的方法?

示例数据:

data2 <- structure(list(Use = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0), Status = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), AnimalID = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,5, 5, 5, 5, 5, 
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), St.A1k = c(0.029627, 0.043414, 
0.113816, 0.000000, 0.020241, 0.000000,0.000000, 0.007334, 0.000000, 
0.046055, 0.028454, 0.042828, 0.018480, 0.106776, 0.018480, 0.046641, 
0.033148, 0.039308, 0.035494, 0.000000, 0.004987, 0.051335, 0.046935, 
0.018774, 0.000000, 0.043708, 0.014667, 0.080375, 0.000000, 0.015254, 
0.000000, 0.053388, 0.055148, 0.036668, 0.006160, 0.016720, 0.029041, 
0.057788, 0.023174, 0.022294, 0.031388, 0.043414, 0.005573, 0.000000, 
0.024054,0.000000, 0.000000, 0.074215, 0.021121, 0.016720, 0.028454, 
0.042828, 0.018480, 0.106776, 0.018480, 0.046641, 0.033148, 0.039308, 
0.035494, 0.000000, 0.000000, 0.053388, 0.055148, 0.036668, 0.006160, 
0.016720, 0.029041, 0.057788, 0.023174, 0.022294,0.031388, 0.043414, 
0.005573, 0.000000, 0.024054, 0.000000, 0.000000, 0.074215, 0.021121, 
0.016720, 0.029627, 0.043414, 0.113816, 0.000000, 0.020241, 0.000000, 
0.000000, 0.007334, 0.000000, 0.046055, 0.029627, 0.043414, 0.113816, 
0.000000, 0.020241, 0.000000, 0.000000, 0.007334, 0.000000, 0.046055), 
InvWeight = c(1.332636, 1.248722, 1.248722, 1.248722, 1.179661, 1, 1, 1, 1, 
1, 1.060296, 1.060296, 1.249593, 1.248595, 1.248626, 1, 1, 1, 1, 1, 
1.294132, 1.740839, 1.740839, 2.377546, 2.377546, 1, 1, 1, 1, 1, 
2.378091,2.378091, 2.378091, 2.378091, 1.060295, 1, 1, 1, 1, 1, 1.060296, 
1.060296, 1.249593, 1.248595, 1.248626, 1, 1, 1, 1, 1, 2.378091, 2.378091, 
2.378091, 2.378091, 1.060295, 1, 1, 1, 1, 1, 2.378091, 2.378091, 2.378091, 
2.378091, 1.060295, 1, 1, 1, 1, 1, 1.294132,1.740839, 1.740839, 2.377546, 
2.377546, 1, 1, 1, 1, 1, 1.332636, 1.248722, 1.248722, 1.248722, 1.179661, 
1, 1, 1, 1, 1, 1.060296,1.060296, 1.249593, 1.248595, 1.248626, 1, 1, 1, 1, 
1)),.Names = c("Use", "Status", "AnimalID", "St.A1k", "InvWeight"), class = 
c("tbl_df", "tbl", "data.frame"), row.names = c(NA, -100L))

具有抽样权重的GLM

des2 <- svydesign(id = ~1,  weights = ~InvWeight, data = data2)
glm.sampling.weights <- svyglm(Use ~ St.A1k, family = binomial, design=des2)
summary(glm.sampling.weights)

GLM(非抽样权重)

glm.w <- glm(Use ~ St.A1k, family = binomial, weight=InvWeight, data=data2)
summary(glm.w)

(来自glm帮助文件:“对于二项式GLM,先前的权重用于表示当响应是成功比例时的试验次数”)。

GEE

cox.w <- coxme(Surv(Status,Use) ~ St.A1k + (1|AnimalID), weight=InvWeight, 
data=data2)
summary(cox.w)

0 个答案:

没有答案