Skip to content
Prev 1351 / 20628 Next

help with a cross-classified random effects model code in R.

On Wed, Sep 3, 2008 at 7:14 AM, Stijn Ruiter <s.ruiter at maw.ru.nl> wrote:
That will estimate the model with crossed random effects.  An example
of exactly this type is
Loading required package: Matrix
Loading required package: lattice

Attaching package: 'Matrix'


	The following object(s) are masked from package:stats :

	 xtabs
Linear mixed model fit by REML
Formula: attain ~ (1 | primary) + (1 | second)
   Data: ScotsSec
   AIC   BIC logLik deviance REMLdev
 17159 17183  -8575    17149   17151
Random effects:
 Groups   Name        Variance Std.Dev.
 primary  (Intercept) 1.13002  1.0630
 second   (Intercept) 0.37222  0.6101
 Residual             8.11069  2.8479
Number of obs: 3435, groups: primary, 148; second, 19

Fixed effects:
            Estimate Std. Error t value
(Intercept)   5.5017     0.1787   30.79

To see that the primary and secondary schools classifications are not
nested you can check the image of the cross classification of those
factors produced by

image(xtabs(~ primary + second, ScotsSec, sparse = TRUE))

I enclose a PDF file of that image.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ScotsSec.pdf
Type: application/pdf
Size: 59109 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20080903/14fce9d1/attachment.pdf>