Dear List:
 
I am having difficulties with the fitted values at different levels of a multilevel model. My data set is a series of student test scores over time with a total of 7,280 observations, 1,720 students nested witin 60 schools. The data set is not balanced.
 
The model was fit using
 
eg.model.1<-lme(math~year, random=~year|schoolid/childid, data=single).
 
When I call the random effects at all levels using 
 
EB.1<-data.frame(ranef(eg.model1, level=1)) and EB.2<-data.frame(ranef(eg.model1, level=2)), I get the shrinkage estimators that I expect. That is, I get 2 random effects for each child (1 intercept and 1 slope) and 2 for each school (1 intercept and 1 slope).
 
However, when I call the fitted values using:
 
fitted<-data.frame(fitted(eg.model1, level=0:2)), I get 7,280 fitted values at the level of observation. This makes sense (one for each observed score). However, I also get 7,280 fitted values at the child and at the school level. This does not seem correct to me.
 
I should only have, I think, 60 fitted values at the school level (actually, 1 intercept and 1 slope for each of 60 schools) and 1,720 fitted values at the child level (again, 1 intercept and one for the slope for each child).
 
Why am I always getting 7,280 fitted values? I have tried
 
fitted.1<-data.frame(fitted(eg.model1, level=1)) and fitted.2<-data.frame(fitted(eg.model1, level=2)), but this does not appear to be working either.
 
Thank you in advance.
 
------
Harold C. Doran
Director of Research and Evaluation
New American Schools
675 N. Washington Street, Suite 220
Alexandria, Virginia 22314
703.647.1628
 <http://www.edperform.net/>  
 
 
 

	[[alternative HTML version deleted]]


