[R-meta] predict function for increment of 0.05 for the moderator

Martineau, Roger Roger.Martineau at AGR.GC.CA
Mon Oct 16 18:52:27 CEST 2017


Dear metafor user,

May be someone can help me on this one.

I am using centered values for a moderator ranging from -0.2 to +0.2 and getting only the prediction for -0.2.
How to get predictions for the range [-0.2 to 0.2] for a fixed increment of 0.05 for example: -0.20, -0.15, -0.10, -0.05, -0.00, 0.05, 0.10, 0.15 and 0.20.

I used the BCG example and created a new centered value for ablat after dividing by 100 (didn’t back-transform to RR purposely).

It looks like I am only obtaining predictions by 1 unit increment (not on a decimal scale).

Thanks in advance,

Roger ☺



library(metafor)

### calculate (log) risk ratios and corresponding sampling variances
(dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg))

dat <- within(dat, {
  Ablat.new <- ablat/100
  cAblat.new  <- Ablat.new - mean(Ablat.new,na.rm = TRUE)
  })

### fit mixed-effects model with absolute latitude as predictor
(res <- rma(yi, vi, mods = ~ cAblat.new, data=dat))


### calculate predicted values for ablat.new
### N.B. omit "trans=exp" for this example


range(dat$cAblat.new)

[1] -0.2046154  0.2153846


# if we predict for the range of values of cAblat.new

(preds <- predict(res, newmods=c(-0.2:0.2), digits=3,addx=TRUE))

  pred    se ci.lb ci.ub  cr.lb cr.ub X.intrcpt X.ablat.new

 0.833 0.384 0.081 1.586 -0.094 1.761         1        -0.2


# if we predict from 0.13 to 5.5:

(preds <- predict(res, newmods=c(-10:10), digits=3,addx=TRUE))

      pred    se   ci.lb   ci.ub   cr.lb   cr.ub X.intrcpt X.ablat.new

1   29.353 7.421  14.807  43.899  14.797  43.909         1         -10

2   26.443 6.702  13.307  39.579  13.296  39.590         1          -9

3   23.533 5.983  11.807  35.258  11.795  35.271         1          -8

4   20.623 5.263  10.307  30.938  10.293  30.952         1          -7

5   17.712 4.544   8.807  26.618   8.790  26.635         1          -6

6   14.802 3.824   7.307  22.298   7.287  22.318         1          -5

7   11.892 3.105   5.806  17.978   5.782  18.002         1          -4

8    8.982 2.386   4.305  13.659   4.274  13.690         1          -3

9    6.072 1.668   2.803   9.340   2.759   9.385         1          -2

10   3.162 0.951   1.298   5.025   1.221   5.102         1          -1

11   0.251 0.249  -0.237   0.740  -0.478   0.981         1           0

12  -2.659 0.506  -3.650  -1.668  -3.788  -1.529         1           1

13  -5.569 1.219  -7.957  -3.180  -8.018  -3.120         1           2

14  -8.479 1.936 -12.274  -4.684 -12.313  -4.645         1           3

15 -11.389 2.655 -16.593  -6.185 -16.621  -6.157         1           4

16 -14.299 3.374 -20.913  -7.686 -20.935  -7.664         1           5

17 -17.210 4.094 -25.233  -9.186 -25.251  -9.168         1           6

18 -20.120 4.813 -29.553 -10.687 -29.568 -10.671         1           7

19 -23.030 5.532 -33.873 -12.187 -33.886 -12.173         1           8

20 -25.940 6.252 -38.193 -13.687 -38.205 -13.675         1           9

21 -28.850 6.971 -42.513 -15.187 -42.524 -15.176         1          10




	[[alternative HTML version deleted]]



More information about the R-sig-meta-analysis mailing list