[R-sig-ME] Trouble fitting large nested models

Douglas Bates bates at stat.wisc.edu
Tue May 31 21:13:28 CEST 2011

On Tue, May 31, 2011 at 1:58 PM, Robert Sandbach <rojosa at gmail.com> wrote:
> Hello everyone.  This is my first time subscribing to and posting to any R
> mailing list, so I am unsure about protocols here.

Thanks for using this list

> Having said that, I have
> been working with my research professor on fitting multi-level models using
> school standardized test data.  We are looking to fit a model where student
> scores over time are nested within students, which are nested within
> teachers.  Additionally, we would like to include random effects on both the
> intercept and on the slope associated with time (in this case, grade
> level).  Unfortunately, the data is quite messy, and some students have just
> one teacher in a school, while other students have several teachers in a
> school.  The following model and analysis still seem run out of memory (or
> at least cause R to crash to a generic Windows "R has a problem and needs to
> close" window with no other error message on a fairly high-powered machine):

Can you tell us the number of observations, number of students and
number of teachers so we can get an idea of the size of the problem?

Also, can you send us the results of the R expressions


as run on the machine that you are using to fit the model?

You definitely want to use a 64-bit operating system when trying to
fit such a model.

> MathVAMForm1 <- as.formula("MATH_SCORE ~ GRADE +
>                            (1 + GRADE | K20_ID:EMPLOYEE_ID) +
>                            (1 + GRADE | EMPLOYEE_ID)")
> MathVAMFit1 <- lmer(MathVAMForm1, Data)
> In this code, K20_ID is a student ID, while the rest of the variables are
> fairly self-explanatory.  We would also like to add a 4th level of nesting,
> teachers within schools, but haven't tried to run that yet since the first
> form did not work.
> Just for the purposes of testing, we ran this model where observations were
> nested within both students and teachers, students were cross-classified
> with teachers but both were nested within schools, as shown below:
> MathPalForm2 <- as.formula("MATH_SCORE ~ GRADE +
>                            (1 + GRADE | K20_ID:INSTITUTION_ID) +
>                            (1 + GRADE | EMPLOYEE_ID:INSTITUTION_ID) +
>                            (1 + GRADE | INSTITUTION_ID)")
> MathPalFit2 <- lmer(MathPalForm2, Data)
> This model fit quickly and (as best we can tell) correctly, although it is
> not really the theoretical model we would like to fit.
> Additionally, for testing, we ran a model that just had observations nested
> within teachers, which were nested within schools, as shown below:
> MathNoStForm3 <- as.formula("MATH_SCORE ~ GRADE +
>                            (1 + GRADE | EMPLOYEE_ID:INSTITUTION_ID) +
>                            (1 + GRADE | INSTITUTION_ID)")
> MathNoStFit3 <- lmer(MathNoStForm3, Data)
> This model also fits quickly and correctly, and is definitely not the
> theoretical model we would like to fit.
> Are there any suggestions on what syntax or setup we might be doing wrong to
> fit our desired model (Form 1 above)?  Additionally, are there any
> characteristics of the data that may be causing trouble with fitting Form 1
> that would not cause trouble with Forms 2 or 3?  We have been scratching our
> heads with this for a bit now, and any feedback would be welcome.  Thanks,
> and have a great day!
> -Robert Sandbach
> (rojosa at gmail.com)
> Graduate Student
> University of Florida
> College of Education
> Research & Evaluation Methodology
>        [[alternative HTML version deleted]]
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

More information about the R-sig-mixed-models mailing list