【问题标题】:R: How to simulate from pooled GLM from miceR:如何模拟来自小鼠的汇集 GLM
【发布时间】:2021-03-13 22:36:39
【问题描述】:

如何在 MICE 的池化 GLM 上使用 simulate 函数?

我在对象miceData 中有我的MICE 估算数据。根据这些数据,我制作了这样的模型:

form3 <- survived ~  sex + age * pclass - 1
glm3 <- glm.mids(data=miceData, form3, family = binomial(link=logit))
glm_pooled <- pool(glm3)

我现在以以下等价方式模拟来自该模型的数据:

form3 <- survived ~  sex + age * pclass - 1
glm3_ref <- glm(form3, family = binomial(link=logit), data = titanic)
yNew <- simulate(glm3_ref)[,1]

我该怎么做?

【问题讨论】:

    标签: r simulation glm r-mice


    【解决方案1】:

    因此,您需要一个 glm 对象,它具有您在 glm_pool 中获得的系数,但在其他方面看起来像通常的(即不基于插补的)glm 输出。

    您可以通过首先从一个完整的数据集(一个插补)创建一个 glm 对象然后更改系数来做到这一点:

    glm_sim <- glm(form3, family = binomial(link=logit), data = mice::complete(miceData, action = 1) )
    glm_sim$coefficients <- glm_pooled$pooled$estimate #please check if the order of estimates is correct!
    

    然后按照您的意图使用glm_sim。但是,正如其他人(比我知道的更多)拥有pointed out,对此要非常谨慎,因为从glm_sim 的其他组件派生的任何内容仍然仅基于单个插补样本,因此无效。例如,模型诊断将毫无用处。

    【讨论】:

      猜你喜欢
      • 2015-03-27
      • 1970-01-01
      • 2023-03-27
      • 2019-08-07
      • 2014-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-14
      相关资源
      最近更新 更多