0

假设我有以下模型结果:

> summary(msa_res@objects[[1]])

Model Results:

         estimate      se     zval    pval    ci.lb    ci.ub     
intrcpt    0.9397  0.0667  14.0850  <.0001   0.8090   1.0705  ***
MAT_e     -0.0079  0.0035  -2.2691  0.0233  -0.0147  -0.0011    *
Naddl     -0.0385  0.0133  -2.9005  0.0037  -0.0645  -0.0125   **

MAT_e我想使用预测函数和Naddl主持人绘制回归线:

preds_MAT_e <- predict(msa_res@objects[[1]], newmods=c(-5:30))
preds_Naddl <- predict(msa_res@objects[[1]], newmods=c(1:6))

但我得到这种类型的错误:

Error in predict.rma(msa_res@objects[[1]], newmods = c(-5:30)) : 
  Dimensions of 'newmods' do not match dimensions of the model.

我想这是因为我没有指定 predict() 函数应该考虑哪个主持人。请注意,上面的函数适用于单变量模型,例如仅使用 MAT_e。

4

1 回答 1

2

当您有两个预测变量时,您需要为这两个预测变量指定值。因此,例如:

predict(msa_res@objects[[1]], newmods=cbind(-5:30, 1))

或者

predict(msa_res@objects[[1]], newmods=cbind(10, 1:6))

因此,您可以保持一个预测变量不变,同时改变另一个。

于 2017-09-03T10:39:14.680 回答