Skip to content

metafor: using mixed models

2 messages · Joris Meys, Viechtbauer Wolfgang (STAT)

#
Dear Joris,

When you call rma() with the (default) argument "intercept=TRUE", then the intercept is added to the X matrix (a column of 1s is added). So, if you use:

fac <- c(1,1,2,3,3,4,4,5,5,5)
X <- model.matrix(~factor(fac))[,2:5]

and then:

rma(ai, bi, ci, di, mods=X, data=testdata, measure="OR")

the final X matrix has 1s in the first column (the intercept), and then the 4 dummies to code levels 2, 3, 4, and 5 in the other columns (with level 1 being the "reference" level, which is not included in the X matrix). So, if you want to test the factor, use:

rma(ai, bi, ci, di, mods=X, data=testdata, measure="OR", btt=2:5)

Or, you can use:

fac <- c(1,1,2,3,3,4,4,5,5,5)
X <- model.matrix(~factor(fac))
rma(ai, bi, ci, di, mods=X, intercept=FALSE, data=testdata, measure="OR", btt=2:5)

which should give you the same results.

I hope this helps!

Best,

--
Wolfgang Viechtbauer                        http://www.wvbauer.com/
Department of Methodology and Statistics    Tel: +31 (0)43 388-2277
School for Public Health and Primary Care   Office Location:
Maastricht University, P.O. Box 616         Room B2.01 (second floor)
6200 MD Maastricht, The Netherlands         Debyeplein 1 (Randwyck)


----Original Message----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Joris Meys Sent:
Monday, January 04, 2010 11:54 To: R mailing list
Subject: [R] metafor: using mixed models