簡體   English   中英

geeglm ((binomial(link="logit")) 使用 glht(multcomp 包)的對比

[英]Contrasts for geeglm ((binomial(link="logit") using glht (multcomp package)

我正在使用 multcomp 包為 R 中的 geeglm (binomial(link="logit") ) 模型生成對比。我正在運行運行以下腳本的 geeglm 模型。

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 

為了獲得模型的對比,我運行了腳本

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!

或者,我嘗試創建一個對比矩陣:

contrast.matrix <- rbind(
  `Other-Black` = c(0, -1, 1))
comps <- glht(u1, contrast.matrix)
summary(comps)

但是,我收到相同的錯誤。 任何有關如何正確生成對比度的幫助將不勝感激。

尊敬,

朱克斯

像這樣的東西?

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")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM