UCLA Academic Technology Services HomeServicesClassesContactJobs
Help the Stat Consulting Group by giving a gift             
Loading

What's New in Stata 9: Linear Mixed Models

This section illustrates the use of xtmixed using examples from the paper Using SAS Proc Mixed to Fit Multilevel Models, Hierarchical Models, and Individual Growth Models by Judith Singer and can be downloaded from Professor Singer's web site.

use http://www.ats.ucla.edu/stat/paperexamples/singer/hsb12

Example on page 329.

Level 1: MathAchij =  β0j + rij  
Level 2: β0j =  γ00 + u0j

Combining the two equations into one by substituting the level 2 equation into the level 1 equation, we have the equation below, with the random effects identified by placing them in square brackets.

MathAchij =  γ00 + [ u0j + rij ]

/* unconditional means model */
xtmixed mathach || school: , variance mle
estat ic

Example on page page 331.

Level 1: MathAchij =  β0j + rij  
Level 2: β0j =  γ00 + γ01(MeanSES) + u0j

Combining the two equations into one by substituting the level 2 equation into the level 1 equation, we have the equation below, with the random effects identified by placing them in square brackets.

MathAchij =  γ00 + γ01(MeanSES) + [ u0j + rij ]

/* random intercept -- level 2 predictor */
xtmixed mathach meanses || school: , variance mle
estat ic

Example on page 335.

Here is the model expressed using multiple equations.

Level 1: MathAchij =  β0j + β1j (cses) + rij  
Level 2: β0j =  γ00  + u0j
Level 2: β1j =  γ10  + u1j

Combining the two equations into one by substituting the level 2 equation to level 1 equation, we have the following with the random effects identified by placing them in square brackets.

MathAchij =  γ00  + γ10(cses) +  [ u1j(cses) + u0j + rij ]   

/* random slopes and random intercept -- level 1 predictor */
xtmixed mathach cses || school: cses, variance cov(un) mle
estat ic

Example on page 337.

We can express this as a multiple equation model like this.

Level 1: MathAchij =  β0j + β1j (cses) + rij  
Level 2: β0j =  γ00  + γ01(MeanSES) + γ02(Sector) + u0j
Level 2: β1j =  γ10  + γ11(MeanSES) + γ12(Sector) + u1j

Combining the two equations into one by substituting the level 2 equations into the level 1 equation, we have the following equation.  The random effects are identified by placing them in square brackets.

MathAchij =   γ00  + γ01(MeanSES) + γ02(Sector) + γ10 (cses) + γ11(MeanSES*cses) +  γ12(Sector*cses) +
     [  u0j + u1j(cses) +  rij ]

/* random slopes and random intercept -- cross level interactions */
generate msesXcses = meanses*cses
generate secXcses = sector*cses

xtmixed mathach meanses sector cses msesXcses secXcses || school: cses, variance cov(un) mle
estat ic




How to cite this page

Report an error on this page or leave a comment

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California