Hi everyone,
I was wondering if it was possible to specify a random effect for a continuous moderator in a multi-level meta-analysis using metafor. When I try to estimate a model, like the one below (using the Konstantopoulos data) I receive an error:
m2.ml <- rma.mv(yi, vi,
random = ~ I(year-1990.591)| district,
method="ML",
digits = 3,
data=dat.konstantopoulos2011)
Here's the error message:
Error: Inner variable in '~ inner | outer' term must be a factor or character variable when 'struct="CS"'.
Any suggestions would be very much appreciated.
Thanks,
Andrew C. Loignon
Assistant Professor
2716 Business Education Complex
Rucks Department of Management
E. J. Ourso College of Business
Louisiana State University
Baton Rouge, LA 70808
Email: aloignon at lsu.edu<mailto:aloignon at lsu.edu>
Phone: 225-578-6148
[R-meta] Random Effect for Continuous Moderator in Three-Level Meta-Analysis
3 messages · Andrew Loignon, Wolfgang Viechtbauer
Hi Andrew,
Yes, this is possible if you install the 'devel' version of metafor. It includes an as-of-yet undocumented 'struct' option, namely "GEN". This allows for random effects terms, such as:
~ x1 + x2 + ... | factor
where x1, x2, and so on can be continuous (but also categorical) variables. So, for the example you used, it would be:
m2.ml <- rma.mv(yi, vi,
random = ~ I(year-1990.591)| district, struct="GEN",
method="ML",
digits = 3,
data=dat.konstantopoulos2011)
BUT:
1) Unless you want to assume that the average slope is 0, one should also include the same predictor as a fixed effect:
m2.ml <- rma.mv(yi, vi, mods = ~ I(year-1990.591),
random = ~ I(year-1990.591)| district, struct="GEN",
method="ML",
digits = 3,
data=dat.konstantopoulos2011)
2) 'year' is actually constant within districts, so the use of random slopes for this predictor doesn't make much sense.
Note: The "GEN" structure is undocumented, which implies that this feature is really still in the testing phase.
Best,
Wolfgang
-----Original Message-----
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-
project.org] On Behalf Of Andrew Loignon
Sent: Thursday, 10 January, 2019 21:08
To: r-sig-meta-analysis at r-project.org
Subject: [R-meta] Random Effect for Continuous Moderator in Three-Level
Meta-Analysis
Hi everyone,
I was wondering if it was possible to specify a random effect for a
continuous moderator in a multi-level meta-analysis using metafor. When I
try to estimate a model, like the one below (using the Konstantopoulos
data) I receive an error:
m2.ml <- rma.mv(yi, vi,
random = ~ I(year-1990.591)| district,
method="ML",
digits = 3,
data=dat.konstantopoulos2011)
Here's the error message:
Error: Inner variable in '~ inner | outer' term must be a factor or
character variable when 'struct="CS"'.
Any suggestions would be very much appreciated.
Thanks,
Andrew C. Loignon
Assistant Professor
2716 Business Education Complex
Rucks Department of Management
E. J. Ourso College of Business
Louisiana State University
Baton Rouge, LA 70808
Email: aloignon at lsu.edu<mailto:aloignon at lsu.edu>
Phone: 225-578-6148
Hi Wolfgang,
Thanks for the quick response and the sample code. I'll try it out!
Best,
Andrew
Andrew C. Loignon
Assistant Professor
2716 Business Education Complex
Rucks Department of Management
E. J. Ourso College of Business
Louisiana State University
Baton Rouge, LA 70808
Email: aloignon at lsu.edu
Phone: 225-578-6148
-----Original Message-----
From: Viechtbauer, Wolfgang (SP) <wolfgang.viechtbauer at maastrichtuniversity.nl>
Sent: Thursday, January 10, 2019 17:47
To: Andrew Loignon <aloignon at lsu.edu>; r-sig-meta-analysis at r-project.org
Subject: RE: Random Effect for Continuous Moderator in Three-Level Meta-Analysis
Hi Andrew,
Yes, this is possible if you install the 'devel' version of metafor. It includes an as-of-yet undocumented 'struct' option, namely "GEN". This allows for random effects terms, such as:
~ x1 + x2 + ... | factor
where x1, x2, and so on can be continuous (but also categorical) variables. So, for the example you used, it would be:
m2.ml <- rma.mv(yi, vi,
random = ~ I(year-1990.591)| district, struct="GEN",
method="ML",
digits = 3,
data=dat.konstantopoulos2011)
BUT:
1) Unless you want to assume that the average slope is 0, one should also include the same predictor as a fixed effect:
m2.ml <- rma.mv(yi, vi, mods = ~ I(year-1990.591),
random = ~ I(year-1990.591)| district, struct="GEN",
method="ML",
digits = 3,
data=dat.konstantopoulos2011)
2) 'year' is actually constant within districts, so the use of random slopes for this predictor doesn't make much sense.
Note: The "GEN" structure is undocumented, which implies that this feature is really still in the testing phase.
Best,
Wolfgang
-----Original Message-----
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-
project.org] On Behalf Of Andrew Loignon
Sent: Thursday, 10 January, 2019 21:08
To: r-sig-meta-analysis at r-project.org
Subject: [R-meta] Random Effect for Continuous Moderator in Three-Level
Meta-Analysis
Hi everyone,
I was wondering if it was possible to specify a random effect for a
continuous moderator in a multi-level meta-analysis using metafor. When
I try to estimate a model, like the one below (using the
Konstantopoulos
data) I receive an error:
m2.ml <- rma.mv(yi, vi,
random = ~ I(year-1990.591)| district,
method="ML",
digits = 3,
data=dat.konstantopoulos2011)
Here's the error message:
Error: Inner variable in '~ inner | outer' term must be a factor or
character variable when 'struct="CS"'.
Any suggestions would be very much appreciated.
Thanks,
Andrew C. Loignon
Assistant Professor
2716 Business Education Complex
Rucks Department of Management
E. J. Ourso College of Business
Louisiana State University
Baton Rouge, LA 70808
Email: aloignon at lsu.edu<mailto:aloignon at lsu.edu>
Phone: 225-578-6148