Consider a longitudinaldataset, used by both Ruppert, Wand, and Carroll (2003) and Diggle etal. (2002), consisting of weight measurements of 48 pigs on 9 successive weeks.Pigs are identified by the variable id. Below is a plot of the growth curvesfor the first 10 pigs.
. usehttp://www.stata-press.com/data/r13/pig (Longitudinalanalysis of pig weights)
. twowayconnected weight week if id<=10, connect(L)
It seems clear that each pig experiences a linear trend ingrowth and that overall weight measurements vary from pig to pig. Because weare not really interested in these particular 48 pigs per se, we instead treatthem as a random sample from a larger population and model the between-pigvariability as a random effect, or in the terminology of (2), as arandom-intercept term at the pig level. We thus wish to fit the model
weightij= β0 + β1weekij + uj + Єij
states that we want one overall regression linerepresenting the population average. The random effect uj serves to shift thisregression line up or down according to each pig. Because the random effectsoccur at the pig level (id), we fit the model by typing
. mixedweight week || id:
Notes:
- By typing weight week, we specified the response, weight, and thefixed portion of the model in the same way that we would if we were using regressor any other estimation command. Our fixed effects are a coefficient on week and a constant term.
- When we added || id:, wespecified random effects at the level identified by the group variable id, that is, the pig level (level two). Becausewe wanted only a random intercept, that is all we had to type.
- The estimation log consists of three parts: (a)A set of EM iterations used to refine starting values. By default,the iterations themselves are not displayed, but you can display them with the emlogoption. (b)A set of gradient-based iterations. By default, these areNewton–Raphson iterations, but other methods are available by specifying theappropriate maximize option.(c)The message “Computing standard errors”. This is just to informyou that mixed has finished its iterative maximization and is nowreparameterizing from a matrix-based parameterization to the natural metric ofvariance components and their estimated standard errors.
- The output title, “Mixed-effects ML regression”, informs us thatour model was fit using ML, the default. For EML estimates, use the reml option. Becausethis model is a simple random-intercept model fit by ML, it would be equivalentto using xtreg with its mle option.
- The first estimation tablereports the fixed effects. We estimate β0 = 19.36 and β1 = 6.21.
- The second estimation table shows theestimated variance components. The first section of the table is labeled id:Identity, meaning that these are random effects at the id (pig) level and that theirvariance–covariance matrix is a multiple of the identity matrix. Because wehave only one random effect at this level, mixed knew that Identity is the onlypossible covariance structure. In any case, the variance of the level-twoerrors is estimated as 4.82 with standard error 3.12.
- The row labeled var(Residual) displays theestimated variance of the overall error term; the variance of the level-oneerrors is 4.38.
- Finally,a likelihood-ratio test comparing the model with one-level ordinary linearregression, model (4) without uj , is provided and is highly significant forthese data.
ME294