The guide entry for xtmixed paperwork all of the official options within the command, and a number of other functions. Nevertheless, it could be not possible to deal with all of the fashions that may be fitted with this command in a guide entry. I need to present you find out how to embrace covariates in a crossed-effects mannequin.
Let me begin by reviewing the crossed-effects notation for xtmixed. I’ll use the homework dataset from Kreft and de Leeuw (1998) (a subsample from the Nationwide Training Longitudinal Research of 1988). You may obtain the dataset from the webpage for Rabe-Hesketh & Skrondal (2008) (http://www.stata-press.com/information/mlmus2.html), and run all of the examples on this entry.
If we need to match a mannequin with variable math (math grade) as end result, and two crossed results: variable area and variable city, the usual syntax can be:
(1) xtmixed math ||_all:R.area || _all: R.city
The underlying mannequin for this syntax is
math_ijk = b + u_i + v_j + eps_ijk
the place i represents the area and j represents the extent of variable city, u_i are i.i.d, v_j are i.i.d, and eps_ijk are i.i.d, and all of them are unbiased from one another.
The usual notation for xtmixed assumes that ranges are all the time nested. With a view to match non-nested fashions, we create a synthetic stage with just one class consisting of all of the observations; as well as, we use the notation R.var, which signifies that we’re together with dummies for every class of variable var, whereas constraining the variances to be the identical.
That’s, if we write
xtmixed math ||_all:R.area
we’re simply becoming the mannequin:
xtmixed math || area:
however we’re doing it in a really inefficient means. What we’re doing is strictly the next:
generate one = 1 tab area, gen(id_reg) xtmixed math || one: id_reg*, cov(identification) nocons
That’s, as a substitute of estimating one variance parameter, we’re estimating 4, and constraining them to be equal. Subsequently, a extra environment friendly option to match our blended mannequin (1), can be:
xtmixed math ||_all:R.area || city:
It will work as a result of city is nested in one. Subsequently, if we need to embrace a covariate (also referred to as random slope) in one of many ranges, we simply want to put that stage on the finish and use the same old syntax for random slope, for instance:
xtmixed math public || _all:R.area || city: public
Now let’s assume that we need to embrace random coefficients in each ranges; how would we try this? The trick is to make use of the _all notation to incorporate a random coefficient within the mannequin. For instance, if we need to match
(2) xtmixed math meanses || area: meanses
we’re assuming that variable meanses (imply SES per college) has a distinct impact (random slope) for every area. This mannequin might be expressed as
math_ik = x_ik*b + sigma_i + alpha_i*meanses_ik
the place sigma_i are i.i.d, alpha_i are i.i.d, and sigmas and alphas are unbiased from one another. This mannequin might be fitted by producing all of the interactions of meanses with the areas, together with a random alpha_i for every interplay, and proscribing their variances to be equal. In different phrases, we are able to match mannequin (2) additionally as follows:
unab idvar: id_reg*
foreach v of native idvar{
gen inter`v' = meanses*`v'
}
xtmixed math meanses ///
|| _all:inter*, cov(identification) nocons ///
|| _all: R.area
Lastly, we are able to use all these instruments to incorporate random coefficients in each ranges, for instance:
xtmixed math parented meanses public || _all: R.area || /// _all:inter*, cov(identification) nocons || city: public
References:
Kreft, I.G.G and de J. Leeuw. 1998. Introducing Multilevel Modeling. Sage.
Rabe-Hesketh, S. and A. Skrondal. 2008. Multilevel and Longitudinal Modeling Utilizing Stata, Second Version. Stata Press
