[R-sig-ME] How to code mixed model with nested factors in lmer
Federico Calboli
f.calboli at imperial.ac.uk
Fri Jun 11 22:50:10 CEST 2010
On 11 Jun 2010, at 19:54, ZHAO, HUIYAN [AG/1005] wrote:
> I have coding question on mixed model in R. I am using R2.11.0 in
> windows. I have an experiment with 2 fixed effect factors - A and B. The
> levels of B are within the levels of A factor. The model is very similar
> to a split plot design except the nesting relationship between the 2
> fixed effect factors. For example: there are 2 levels for A - GM and ZM.
> There are 7 levels of B in total (G1-G4 and Z1 - Z3) - but G1, G2, G3,
> G4 only appear in GM while Z1, Z2 and Z3 only appear in ZM. The SAS code
> is like the following:
> I tried to code this model in R using lmer(). It turned out that R has
> some issues with nesting levels with fixed effect. I changed and tried a
> few models just for diagnostic purpose. And I found whenever I included
> the nesting fixed effects, I got the following error message: "Problem
> in .C("mixed_EM",: Singularity in backsolve, while calling subroutine
> mixed_EM". I am wondering whether someone can help me set up this mixed
> model in R.
no idea of the error you're getting, but assuming that:
1) B is a *random* factor
2) the levels of B are uniquely coded G1:G4 and Z1:Z3, i.e. GX is only found in level 1 of A and ZX is only found in level 2 of A
my hunch is the formula should be
lmer(y ~ A + (1|B), data)
I am pretty sure the formula for lme (library nlme)
is
lme(y ~ A, random = ~1|B, data)
You have not provided us with the code you're running, so I find it difficult to figure out why you get that error. BTW, if B is a *fixed* factor, why not using
aov(y ~ A + B%in%A, data)
??
F
--
Federico C. F. Calboli
Department of Epidemiology and Biostatistics
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG
Tel +44 (0)20 75941602 Fax +44 (0)20 75943193
f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com
More information about the R-sig-mixed-models
mailing list