【问题标题】:Comparing nested mice models with interaction terms将嵌套小鼠模型与交互项进行比较
【发布时间】:2015-04-21 15:22:12
【问题描述】:

R 的mice 包含一个函数pool.compare,用于比较适合估算对象的嵌套模型。如果我尝试包含交互术语:

library(mice)
imput = mice(nhanes2)
mi1 <- with(data=imput, expr=lm(bmi~age*hyp))
mi0 <- with(data=imput, expr=lm(bmi~age+hyp))
pc  <- pool.compare(mi1, mi0, method="Wald")

然后它返回以下错误:

Error in pool(fit1) : 
  Different number of parameters: coef(fit): 6, vcov(fit): 5

听起来方差-协方差矩阵不包含交互项作为其自己的变量。解决这个问题的最佳方法是什么?

【问题讨论】:

    标签: r r-mice


    【解决方案1】:

    问题似乎是您的某些参数在您的某些估算数据集中无法估计。当我运行代码时,我看到了

    ( fit1<-mi1$analyses[[1]] )
    # lm(formula = bmi ~ age * hyp)
    # 
    # Coefficients:
    # (Intercept)         age2         age3         hyp2    age2:hyp2  
    #      28.425       -5.425       -3.758        1.200        3.300  
    #   age3:hyp2  
    #          NA  
    

    在这组中,无法估计age3*hyp2(可能是因为在这组中没有观察到)。

    这会导致 coef(fit1)vcov(fit1) 的差异,因为无法估计该术语的协方差。

    在这种情况下要做什么更多的是统计问题而不是编程问题。如果您不确定什么适合您的数据,我建议您通过Cross Validated 咨询统计学家。

    【讨论】:

    • 有道理。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-24
    • 2021-05-22
    • 1970-01-01
    • 1970-01-01
    • 2020-02-26
    • 2016-02-16
    • 2023-03-05
    相关资源
    最近更新 更多