转载
链接: https://www.codesd.com/item/confidence-interval-of-coefficients-using-the-generalized-estimation-equation-ege.html.
链接: https://stackoverflow.com/questions/21221280/confidence-interval-of-coefficients-using-generalized-estimating-equation-gee.
需要明确,在置信度(检验水准为0.05)确定的情况下置信区间的计算需要Estimate(系数样本估计值)和Std.err(标准误)
即upr=Estimate+1.96Std.err
lwr=Estimate-1.96Std.err
方法一
这个方法不能得到哑变量的系数,只能得到这个变量的系数;比如说Time这个变量是3个水平,两个哑变量,按照方法一只能得到Time这个变量的,无法得到Time2和TIme3参照于TIme1的。
library(geepack)data(dietox)dietox$Cu <- as.factor(dietox$Cu)mf1 <- formula(Weight~Cu*poly(Time,3))gee1 <- geeglm(mf1, data=dietox, id=Pig, family=poisson("identity"),corstr="ar1")cc <- coef(summary(gee1))citab <- with(as.data.frame(cc), cbind(lwr=Estimate-1.96*Std.err, upr=Estimate+1.96*Std.err))rownames(citab) <- rownames(cc)
方法二
自己定义confint函数,因为confint函数在geeglm函数中无法使用
confint.geeglm <- function(object, parm, level = 0.95, ...) { cc <- coef(summary(object)) mult <- qnorm((1+level)/2) citab <- with(as.data.frame(cc), cbind(lwr=Estimate-mult*Std.err, upr=Estimate+mult*Std.err)) rownames(citab) <- rownames(cc) citab[parm,]}confint(gee1)