Re: [R] Problem in lme4

From: Douglas Bates <bates_at_stat.wisc.edu>
Date: Sat 03 Jul 2004 - 02:26:20 EST

Doran, Harold wrote:

> I was able to run the following in nlme successfully, but the same model
> and code (same dataset) failed to run in lme4 and gave me the error
> message below. Any thoughts?
>
>
> lme(math~year, data=egsingle, random=~year|schoolid/childid)
>
>
> Error in lme(formula = math ~ year, data = egsingle, random =
> structure(list( :
>
> Unable to invert singular factor of downdated X'X

Is childid unique? If not, you will need to generate a unique id for the child for the lme4 version of lme. (This change is required because the lme4 package can fit models with crossed or partially crossed grouping factors.)

A simple way of creating the necessary factor (thanks to Martin Maechler for showing me this) is

egsingle$chld <- (egsingle$schoolid : egsingle$childid)[drop = TRUE]

(I haven't checked this. I don't have R on the machine that I use for email connectivity. I can check this later today. Is the egsingle data set the same one you sent me earlier?)



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 03 02:27:19 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:16:50 EST