Skip to content

[R-meta] predict error in metafor

9 messages · Fatih ÇELİK, Wolfgang Viechtbauer, Fatih Çelik

#
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20230317/e2cea8bf/attachment.html>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 07E6B0FED9334E889B0D1CA01BC402CE.png
Type: image/png
Size: 2336 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20230317/e2cea8bf/attachment.png>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 18A62EF59EF649C5903A71D147066AA8.png
Type: image/png
Size: 1491 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20230317/e2cea8bf/attachment-0001.png>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1AA8D9C5AB54460BA519F64955015C66.png
Type: image/png
Size: 855 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20230317/e2cea8bf/attachment-0002.png>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: A00C288E1A044FBC9E16B6D37BF06BC3.jpg
Type: image/jpeg
Size: 1279 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20230317/e2cea8bf/attachment.jpg>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: A7D6181A72C34F60B85632BCD8A8408D.png
Type: image/png
Size: 1294 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20230317/e2cea8bf/attachment-0003.png>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: A9A8A9FFAC1A451691F9A1AC9C27A293.png
Type: image/png
Size: 1321 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20230317/e2cea8bf/attachment-0004.png>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: BB89D61EE1EE47EAAB7CF3D76D6D7274.png
Type: image/png
Size: 479 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20230317/e2cea8bf/attachment-0005.png>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: E04A062320094EDBB36B3BB1A9B9B8FA.png
Type: image/png
Size: 471 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-meta-analysis/attachments/20230317/e2cea8bf/attachment-0006.png>
#
Dear Fatih,

First of all, given that the error message says that the model matrix contains 4 columns, there must be four levels to the 'publications' factor, not three (i.e., aside from article, book sections, and thesis, there must be another level).

table(dat$publications)

will tell you what the levels are.

And if you look at the output from 'res', you will see that the model contains three dummy variables, one for each level except the reference level, corresponding to the model intercept.

So, to use predict(), you have to specify the values for the three dummy variables. In particular,

predict(res, newmods=c(0,0,0), digits=3)
predict(res, newmods=c(1,0,0), digits=3)
predict(res, newmods=c(0,1,0), digits=3)
predict(res, newmods=c(0,0,1), digits=3)

will give you the predicted average effect (or in this case, alpha) for each level (including the reference level). Or more compactly:

predict(res, newmods=rbind(0,diag(3)), digits=3)

Best,
Wolfgang
#
That is correct.

Best,
Wolfgang
#
When fitting the model, use rma(..., test="knha").

P.S.: Please post in plain text, as explained here:

https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis

Best,
Wolfgang
1 day later
#
Hello, sir.

As you pointed out, when I run the Knapp-Hartung test, Qw (statistic
for testing the model misspecification) does not appear in the output.
How can I access this value? Below I first present to you the model I
created and then the output.

Model:

res1 <- rma(measure="ARAW", ai=ai, mi=mi, ni=ni, mods = ~ sample,
test="knha", data=dat)

 outputs:

 Mixed-Effects Model (k = 85; tau^2 estimator: REML)

tau^2 (estimated amount of residual heterogeneity):     0.0021 (SE = 0.0004)
tau (square root of estimated tau^2 value):             0.0457
I^2 (residual heterogeneity / unaccounted variability): 94.01%
H^2 (unaccounted variability / sampling variability):   16.70
R^2 (amount of heterogeneity accounted for):            0.00%

Test for Residual Heterogeneity:
QE(df = 83) = 2139.6714, p-val < .0001

Test of Moderators (coefficient 2):
F(df1 = 1, df2 = 83) = 0.9652, p-val = 0.3287

Model Results:

               estimate      se     tval  df    pval    ci.lb   ci.ub
intrcpt          0.8286  0.0102  81.0985  83  <.0001   0.8083  0.8489  ***
samplestudent   -0.0117  0.0119  -0.9825  83  0.3287  -0.0354  0.0120

---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1



---



Yours sincerely?



Kimden: Viechtbauer, Wolfgang (NP)
G?nderilme: 18 Mart 2023 Cumartesi 15:57
Kime: Fatih ?EL?K; R Special Interest Group for Meta-Analysis
Konu: RE: predict error in metafor



When fitting the model, use rma(..., test="knha").



P.S.: Please post in plain text, as explained here:



https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis



Best,

Wolfgang
#
The F-test replaces the Qw statistic when using test="knha" (it tests the same thing, but now based on the K&H method).

Best,
Wolfgang