我正在尝试分析 R 中的非劣效性试验。由于存在相关观察结果并且总体平均解释似乎不错,因此我想使用 GEE。
为了说明我的问题,我将使用 R 中嵌入 gee 包中的 muscatine 数据。 研究问题可以如下,我想调查马斯卡廷数据中的男性参与者与女性相比是否具有不劣质的肥胖水平(因此相当于测试“男性”是否是一种新的、不劣于女性的药物)标准药物“女性”)
结果“肥胖”和变量“性别”都是二元的,年龄和场合是受控且连续的(不过并不重要)
我使用了以下代码:
library(gee)
data(muscatine)
data2 <- muscatine
data2$obese <- ifelse(muscatine$obese == 'yes', 0, 1)
x <- gee(obese ~ gender + age + occasion, id = id, family = binomial, corstr = "exchangeable", data = data2)
summary(x)
这给了我以下关于系数的输出:
Coefficients:
Estimate Naive S.E. Naive z Robust S.E. Robust z
(Intercept) 1.7846 0.1152 15.49 0.1116 16.00
genderF -0.1521 0.0620 -2.45 0.0626 -2.43
age -0.0296 0.0113 -2.63 0.0110 -2.68
occasion -0.0377 0.0298 -1.27 0.0310 -1.22
提前感谢救星!
我收回了我的投票,因为我认为问题在于OP不知道如何在R回归公式中设置偏移项。偏移量是模型中的一个参数,假设测量时没有不确定性,通常用于针对 0 以外的 H_0 进行测试。在 R(以及任何具有 GLM 的建模软件)中使用偏移量的另一个考虑因素是偏移量需要输入时要考虑到链接函数,因此对于二项式模型,偏移量需要是在非转换数据中假设的效应大小的对数。
(所提供代码的另一个问题是
muscatine
不是 pkg:gee
中的数据元素,而是 pkg:geepack
中的数据元素)
if(!require(gee)){install.packages("gee"); library(gee)}
if(!require(geepack)){install.packages("geepack"); library(geepack)} # for muscatine
data2 <- muscatine
data2$obese <- ifelse(muscatine$obese == 'yes', 0, 1)
# add offset term with log of hypothesized H_0
x <- gee(obese ~ gender + age + occasion+offset(rep(log(0.1), nrow(data2))), id = id, family = binomial, corstr = "exchangeable", data = data2)
#-----message from gee() --------
Beginning Cgee S-function, @(#) geeformula.q 4.13 98/01/27
running glm to get initial regression estimate
(Intercept) genderF age occasion
4.00334630 -0.12601405 -0.02556356 -0.01632539
summary(x)
#---------output begins here----------------
GEE: GENERALIZED LINEAR MODELS FOR DEPENDENT DATA
gee S-function, version 4.13 modified 98/01/27 (1998)
Model:
Link: Logit
Variance to Mean Relation: Binomial
Correlation Structure: Exchangeable
Call:
gee(formula = obese ~ gender + age + occasion + offset(rep(log(0.1),
nrow(data2))), id = id, data = data2, family = binomial,
corstr = "exchangeable")
Summary of Residuals:
Min 1Q Median 3Q Max
-0.97960924 0.02160615 0.02569267 0.02857506 0.03592698
Coefficients:
Estimate Naive S.E. Naive z Robust S.E. Robust z
(Intercept) 4.0872254 0.11518402 35.484310 0.11155396 36.638999
genderF -0.1520871 0.06198955 -2.453431 0.06261391 -2.428966
age -0.0295689 0.01126046 -2.625906 0.01102506 -2.681973
occasion -0.0377399 0.02983178 -1.265090 0.03096084 -1.218956
Estimated Scale Parameter: 0.990456
Number of Iterations: 3
Working Correlation
[,1] [,2] [,3]
[1,] 1.0000000 0.5400174 0.5400174
[2,] 0.5400174 1.0000000 0.5400174
[3,] 0.5400174 0.5400174 1.0000000