【问题标题】:Out of sample prediction for rma object in metaformetafor 中 rma 对象的样本外预测
【发布时间】:2018-06-11 19:04:06
【问题描述】:

估计回归模型后,通常会提取预测值。但我不知道如何在metafor::rma(中做到这一点

library(metafor)

res <- rma(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg,
       mods = ~ ablat + year, 
       data=dat.bcg)

predict(res, 
    newdata = expand.grid(
      year = 1980,
      ablat = 30:55
      )
    )

它返回 13 个拟合值(数据中的行用于估计 rma 对象,而不是 expand.grid( 对象中的 25 行。

如何对新的data.frame 进行样本外预测?

【问题讨论】:

    标签: r regression metafor


    【解决方案1】:

    ?predict.rma 的帮助文件将参数指定为newmods 而不是newdata,它似乎需要矩阵而不是data.frame。这应该工作

    predict(res, 
            newmods = as.matrix(expand.grid(
              ablat = 30:55,
              year = 1980
            ))
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-06
      • 1970-01-01
      • 1970-01-01
      • 2017-10-20
      • 1970-01-01
      • 2017-10-24
      • 2019-05-15
      • 2015-03-05
      相关资源
      最近更新 更多