[R-meta] predict error in metafor
Viechtbauer, Wolfgang (NP)
wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Fri Mar 17 16:32:07 CET 2023
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).
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)
>From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org] On
>Behalf Of Fatih ÇELIK via R-sig-meta-analysis
>Sent: Friday, 17 March, 2023 15:30
>To: r-sig-meta-analysis using r-project.org
>Cc: Fatih ÇELİK
>Subject: [R-meta] predict error in metafor
>While doing meta-analysis (reliability generalization) on R metafor, I am having
>trouble and I can't get over it.
>I want to do moderator analysis with a categorical variable feature over
>"publications" (i.e. article, book sections, and thesis). For this, I use the
>res<- rma(measure="ARAW", ai=ai, mi=mi, ni=ni, mods = ~ publications, data=dat)
>predict(res, newmods=c(0, 1), digits=3)
>However, when I run predict code (recent code), it gives the following error.
>Error in predict.rma(res4, newmods = c(0, 1), digits = 3) :
>Dimensions of 'newmods' (3) do not the match dimensions of the model (4).
>As far as I understand, it gives this error because there are more than two
>categories. Because when I analyse a different variable with two categories (like
>female and male), it does the “predict” operation without giving an error. Can
>you help me, please? How else can I edit and run this code (predict)?
>Ph.D. Fatih ÇELİK
>Trabzon Üniversitesi/Trabzon University
>Vakfıkebir Meslek Yüksekokulu/Vakfikebir Vocational School
>Pazarlama ve Reklamcılık Bölümü/Department of Marketing and Advertising
>0462 455 46 80-----4687-4685
>fatihcelik using trabzon.edu.tr fatihcelik2842 using gmail.com
More information about the R-sig-meta-analysis