首页 > 编程知识 正文

r语言绘制密度估计曲线,r语言求置信区间的函数

时间:2023-05-04 03:25:31 阅读:248484 作者:2866

转载
链接: 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)
Redis7.0部署集群怎么实现添加Geofence使ApiException状态为13

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。