# Calculating level 2 variable based on mean of level 1 variable with multilevel model in R

I have 299 surveys collected from 299 individuals working at 26 different locations. I want to understand how the location specific features relate to the individual survey scores. The only inference I have as to location features is gathered from the individual survey scores. Is it a valid strategy to calculate means for each location based on the individual scores, and include this as a level 2 variable? Further, does it also make sense to include the same variable but as the level 1 variable, with slope varying freely between locations, if I want to compare the relative usefulness of the mean (best estimate of 'reality') to a persons individual score? (their perception of reality and response biases).

I feel like I may have some circularity in the logic. My implementation in R for one of the variables of interest follows, any feedback is welcome!

lmer(X21~X25+meanX25+(X25|X1),data=datai)
Linear mixed model fit by REML
Formula: X21 ~ X25 + meanX25 + (X25 | X1)
Data: datai
AIC  BIC logLik deviance REMLdev
1079 1105 -532.7     1056    1065
Random effects:
Groups   Name        Variance Std.Dev. Corr
X1       (Intercept) 0.384983 0.62047
X25         0.012382 0.11127  -1.000
Residual             1.936068 1.39143
Number of obs: 299, groups: X1, 26
Fixed effects:
Estimate Std. Error t value
(Intercept)  1.13616    0.38013   2.989
X25          0.56683    0.05265  10.766
meanX25      0.33897    0.12213   2.775

Correlation of Fixed Effects:
(Intr) X25
X25     -0.119
meanX25 -0.838 -0.389

-
 I don't know why my R output posts so badly, it look ok in the editor, I can't seem to fix it... – Charlie Nov 15 '12 at 8:37 You have to indent it with 4 spaces manually or by selecting and clicking {} button. – mbq♦ Nov 15 '12 at 9:43