Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Multiple group latent growth models with xtmixed


From   Scott Baldwin <baldwinlist@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Multiple group latent growth models with xtmixed
Date   Mon, 23 Nov 2009 13:16:11 -0700

John Holmes asked:

"I have been estimating latent growth models using -xtmixed- with a
continuous income measure as the dependent variable and long-term
family status (14 categories) as an independent variable.  However, I
am wanting to estimate simultaneous models for two separate groups -
those poor at time=0 and those not poor at time=0.  Is this possible
using xtmixed?"

You can. Given that you are calling your analysis a latent growth
model, I assume you are coming from SEM framework. Anyhow, you can fit
the mixed model version of a multiple group model using a separate
intercepts separate slopes model. Note, however, this is equivalent to
including the grouping variable as a main effect and as an interaction
with the time variable. It is just a reparamaterization of the typical
interaction model. In any case, the following code using the
"childweight" data described in the xtmixed documentation will
illustrate what you have to do.

Hope this helps.

Best,
Scott

******************************
use http://www.stata-press.com/data/r11/childweight, clear

*fit the typical interaction model
gen agegirl=age*girl
xtmixed weight age girl agegirl || id: age, var cov(un) ml

------------------------------------------------------------------------------
      weight |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |   3.575854   .1770211    20.20   0.000     3.228899    3.922809
        girl |  -.4639727   .2933195    -1.58   0.114    -1.038868    .1109229
     agegirl |  -.2358053   .2501978    -0.94   0.346     -.726184    .2545733
       _cons |   5.345483   .2063143    25.91   0.000     4.941114    5.749851
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured             |
                    var(age) |   .1988519   .1258059      .0575449    .6871511
                  var(_cons) |   .0540533   .0844623      .0025279    1.155816
              cov(age,_cons) |    .103675   .0602908     -.0144927    .2218428
-----------------------------+------------------------------------------------
               var(Residual) |   1.350626   .1634692      1.065399    1.712214
------------------------------------------------------------------------------

*log-likelihood
display(e(ll))
-338.6593

*note that the _cons is equivalent to the boys' intercept when age
equals zero and the the coefficient for girl is the difference between
the boys' intercept and the girls' intercepts. Likewise, the age
coefficient is the slope for boys and the age x girl interaction is
the difference between the boys' and girls' slopes.


*fit the separate intercepts and slopes model. You need to create
indicator variables for each level of your grouping variable. We're
going include both and suppress the intercept. So I will create two
new dummy variables called male (1 for boys, 0 for girls) and female
(1 for girls, 0 for boys). We're also going to create the interaction
between the new dummy variables and the age variable. We aren't going
to include a main effect for age.
tab girl, gen(sex)
rename sex1 male
rename sex2 female
gen agemale=age*male
gen agefemale=age*female
xtmixed weight male agemale female agefemale, nocons || id:age, var cov(un) ml
------------------------------------------------------------------------------
      weight |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        male |   5.345483   .2063144    25.91   0.000     4.941115    5.749852
     agemale |   3.575854   .1770212    20.20   0.000     3.228899    3.922809
      female |    4.88151   .2084964    23.41   0.000     4.472865    5.290156
   agefemale |   3.340048   .1768121    18.89   0.000     2.993503    3.686594
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured             |
                    var(age) |   .1988517   .1258081      .0575436     .687166
                  var(_cons) |   .0540512   .0844627      .0025274    1.155925
              cov(age,_cons) |    .103673   .0602922     -.0144975    .2218435
-----------------------------+------------------------------------------------
               var(Residual) |    1.35063   .1634699      1.065402    1.712219
------------------------------------------------------------------------------

*log-likelihood
display(e(ll))
-338.6593

*note that the fit is identical to the previous model. We just
reparamaterized things. The male and female coefficients are the
intercepts for males and females, respectively. The agemale and
agefemale coefficients are the slopes for age for males and females,
respectively.

*With a little arithmetic, you can move between the coefficients in
this model and the coefficients in the previous model. For example, to
get the coefficient for girl from the first model take the difference
between the female and male coefficients.
display 4.88151-5.345483
-.463716

*You can also estimate separate random effects across groups
xtmixed weight male agemale female agefemale, nocons || id:male
agemale, nocons cov(un)  || id:female agefemale, nocons var cov(un) ml

*And if you have Stata 11, you can easily estimate separate residual
errors. It is more complicated in Stata 10.
xtmixed weight male agemale female agefemale, nocons || id:male
agemale, nocons cov(un)  || id:female agefemale, nocons var cov(un)
residuals(independent, by(girl)) ml

*Finally, you could use an likelihood ratio-test to see if fitting
separate intercepts and slopes improves model fit.

xtmixed weight age || id:age, var cov(un) ml
estimates store model1
xtmixed weight male agemale female agefemale, nocons || id:age, var cov(un) ml
estimates store model2
lrtest model1 model2
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index