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
> Dear all,
>
> I'm currently applying a mixed model approach to meta analysis using
> the package metafor. I use the "model.matrix()" function to
create
> dummy variables. The option btt gives me the combined test for the
> dummies. Problem is, I don't know which indices I have to use, and
> can't really figure it out from the help file and the examples. I use
> following code :
>
> X <- model.matrix(~factor, data=testdata)[,2:5] # to exclude the
> intercept. Otherwise I get singular issues in the rma model
>
> rma(ai, bi, ci, di, mods=X,
data=testdata,btt=c(2:5),measure="OR")
>
> Now I'm not sure whether btt reads the model intercept of rma as
> index 1, or the first dummy as index 1. So I'm not sure if I should
> use :
>
> rma(ai, bi, ci, di, mods=X,
data=testdata,btt=c(1:4),measure="OR")
>
> from the examples in the help files, I should use the first option.
> But there I see no option used to exclude an intercept from the model
> matrix. All help greatly appreciated. Thank you in advance Joris
>
>
> --
> Joris FA Meys
> Statistical Consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> Coupure Links 653
> B-9000 Gent
>
> tel : 09/ 264 59 87
> Joris.Meys at Ugent.be
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.