[R] How to run interaction between to categoric variables in lme()?
Dieter Menne
dieter.menne at menne-biomed.de
Wed Jan 30 16:13:03 CET 2008
Falco tinnunculus <kestrel78 <at> gmail.com> writes:
> How do I run interaction between to categoric variables in lme()?
>
> I tried this:
>
> > lmefit1<- lme(Handling ~Mass+factor(Prey)+factor (Decap)+
> factor(Prey)*factor(Decap), random = ~ 1 |Place, data=nestling1)
>
> Error in MEEM(object, conLin, control$niterEM) :
> Singularity in backsolve at level 0, block 1
First, I would suggest that you make Prey, Decap factors in your data frame.
Makes for a much easier reading, and fewer errors if you test
nestling1$Prey = as.factor(nestling1$Prey)
nestling1$Decap = as.factor(nestling1$Decap)
lmefit1<- lme(Handling ~Mass+Decap*Prey, random = ~ 1 |Place, data=nestling1)
You should not write
Prey+Decap+Prey*Decap.
I you want to do it explicitly, used the colon instead
Prey+Decap+Prey:Decap
or, let lme do the dirty (i.e. in most cases correct) work:
Prey*Decap
which will expand to what you need. If you still get the error message, it's
your data: you want to much from them. Check if you have enough degrees of
freedom left, or if the data set is degenerate by not including a sufficient
number of pairing.
Dieter
More information about the R-help
mailing list