[R] metafor- interpretation of moderators test for raw proportions
Viechtbauer Wolfgang (STAT)
wolfgang.viechtbauer at maastrichtuniversity.nl
Sat Aug 4 18:31:13 CEST 2012
Just to follow up on what Michael wrote:
I cannot reproduce that error. For example, this all works as intended:
data(dat.bcg)
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, append=TRUE)
rma(yi, vi, mods = ~ alloc, data=dat) ### 'alloc' automatically converted to a factor
dat$alloc <- factor(dat$alloc) ### explicitly make 'alloc' a factor
rma(yi, vi, mods = ~ alloc, data=dat) ### works as before
rma(yi, vi, mods = ~ factor(alloc), data=dat) ### factor() not necessary, but works
If you can provide a reproducible example, I'll be glad to look into the issue.
Aside from that, the error you got occurs when the design matrix is not of full rank. For example:
X <- model.matrix(~ factor(alloc) - 1, data=dat)
rma(yi, vi, mods = X, data=dat)
will fail, because the model now has an intercept plus the 3 dummy variables for the 3 levels (setting intercept=FALSE will make this work). It seems to me that this is what happened (since in your previous post, you showed that you coded the three levels of your factor manually). But this is something different than what you describe below, so I don't know for sure.
Best,
Wolfgang
________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of cpanderson [christopher.p.anderson at healthpartners.com]
Sent: Friday, August 03, 2012 6:03 PM
To: r-help at r-project.org
Subject: Re: [R] metafor- interpretation of moderators test for raw proportions
Wolfgang,
Thanks for your quick response. You are correct- indeed I had inadvertently
left out that i had set intercept = FALSE in rma.
Following your suggestions, I get the following results:
Test of Moderators (coefficient(s) 2,3):
QM(df = 2) = 0.2207, p-val = 0.8955
Model Results:
estimate se zval pval ci.lb ci.ub
intrcpt 0.6498 0.0492 13.2160 <.0001 0.5534 0.7462 ***
Complex 0.0457 0.1007 0.4538 0.6500 -0.1517 0.2430
Dome 0.0244 0.1135 0.2148 0.8299 -0.1980 0.2468
This may be an even dumber question than my first one, but if you have time
I'd appreciate knowing how this works. Originally I had tried the syntax
mods = ~ Technique. I ended up getting the following error message:
Error in qr.solve(wX, diag(k)) : singular matrix 'a' in solve
if I supply the argument that mods =~ factor(Technique), I don't get the
singular matrix 'a' message. But I don't understand why that should make a
difference, because dat$Technique is already an object of class factor:
class(dat$Technique)
[1] "factor"
Thanks again.
Christopher
More information about the R-help
mailing list