首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用glht (multcomp包)的geeglm ((二项式(link=“logit”))的对比

使用glht (multcomp包)的geeglm ((二项式(link=“logit”))的对比
EN

Stack Overflow用户
提问于 2018-10-25 00:17:14
回答 1查看 193关注 0票数 1

我正在使用multcomp包为R中的geeglm (二项式(link=“logit”))模型生成对比。我正在运行geeglm模型,运行以下脚本。

代码语言:javascript
复制
Library(geepack)
u1<-geeglm(outcome~ px_race_jama,id=npi_gp, family=binomial(link="logit"),data=mf)
Summary(u1)

Call:
geeglm(formula = outcome ~ px_race_jama, family = binomial(link = "logit"), 
    data = mf, id = npi_gp)

     Coefficients:
                  Estimate Std.err Wald Pr(>|W|)   
    (Intercept)    -0.4671  0.1541 9.19   0.0024 **
    px_race_jama1   0.0959  0.1155 0.69   0.4067   
    px_race_jama2  -0.0293  0.1503 0.04   0.8453   
    ---
    Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    Estimated Scale Parameters:
                Estimate Std.err
    (Intercept)        1  0.0506
    Correlation: Structure = independenceNumber of clusters:   83   Maximum cluster size: 792 

为了获得模型的对比度,我运行以下脚本

代码语言:javascript
复制
Library(multcomp)
glht(u1,mcp(px_race_jama="Tukey"))
I receive the error:
Error in match.arg(type) : 
  'arg' should be one of “pearson”, “working”, “response”
Error in modelparm.default(model, ...) : 
  no ‘vcov’ method for ‘model’ found!

或者,我尝试创建一个对比度矩阵:

代码语言:javascript
复制
contrast.matrix <- rbind(
  `Other-Black` = c(0, -1, 1))
comps <- glht(u1, contrast.matrix)
summary(comps)

但是,我收到了相同的错误。任何关于如何正确生成对比度的帮助都将不胜感激。

恕我直言,

Jdukes

EN

回答 1

Stack Overflow用户

发布于 2021-01-27 23:35:59

像这样的东西?

代码语言:javascript
复制
contrast.matrix <- matrix(c(0,-1,1,
                            0,1,-1),nrow=2,byrow=TRUE)

contrasts_geeglm <- function(fit,model_matrix,vcov_type = "robust"){
  
  vcov_gee = if(vcov_type =="robust"){
    fit$geese$vbeta}else{fit$geese$vbeta.naiv}
  
  contrast_est = coef(fit)%*%t(model_matrix)
  contrast_se = sqrt(model_matrix%*%vcov_gee%*% t(model_matrix))
  
  output = data.frame(Estimate = contrast_est[1,],
                      SE = diag(contrast_se)) %>% 
    mutate(LCI = Estimate - 1.96*SE,
           UCI = Estimate + 1.96*SE)
  
  return(output)
}

contrasts_geeglm(u1,contrast.matrix,vcov_type="robust")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52973713

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档