代码之家  ›  专栏  ›  技术社区  ›  tomw

Metafor中RMA对象的样本外预测

  •  0
  • tomw  · 技术社区  · 7 年前

    在对回归模型进行估计后,通常需要提取预测值。但我不知道怎么做 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( 对象。

    如何在新的 data.frame 是吗?

    1 回复  |  直到 7 年前
        1
  •  1
  •   MrFlick    7 年前

    的帮助文件 ?predict.rma 将参数指定为 newmods 而不是 newdata 它似乎需要一个矩阵而不是一个数据框架。这应该管用

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