Statalist


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

Re: st: Multiple group latent growth models with xtmixed


From   Stas Kolenikov <[email protected]>
To   [email protected]
Subject   Re: st: Multiple group latent growth models with xtmixed
Date   Tue, 24 Nov 2009 13:23:30 -0600

Scott's suggestion gives you almost exactly what you need. He rendered
the multiple group analysis of the linear predictor with the second
model in which the two genders had separate intercepts and slopes
(note the -nocons- option that gives you identification of the
constant). It is just a matter of grouping the estimates in the final
table.

If you need the full fledge multiple group analysis with every
parameter broken down into groups (and you would want to think about
various invariances between your groups, really), you could also want
to model the variances according to your poor/nonpoor status (gender
in Scott's example). My naive attempt to do that with -xtmixed-,
however, failed:

xtmixed weight male agemale female agefemale, nocons || id:agemale
agefemale, var cov(un) ml coll

returns missing standard errors for the random effects. It probably
could be fixed by imposing a block structure on that matrix, but
-xtmixed- does not have that as an option.

You can model the variances at all levels in -gllamm-. Continuing with
Scott's example, you can entertain the following models:

* random intercepts
gllamm weight male agemale female agefemale, nocons i(id)
mat bb1 = e(b)

* random intercepts and slopes, the analogue of -xtmixed-
eq rsl : age
gen one = 1
eq rcs : one
gllamm weight male agemale female agefemale, nocons i(id) eqs( rsl rcs
) nrf(2) nip(4 4) from( bb1 ) skip
* nip is low to ensure faster convergence
mat bb2 = e(b)

* random intercepts and slopes by group
eq male : male
eq female : female
eq agemale : agemale
eq agefemale : agefemale
gllamm weight male agemale female agefemale, nocons i(id) eqs( male
female agemale agefemale ) nrf(4) nip(4 4 4 4) from( bb2 ) skip
* this model has some weird results in the variance part -- may be the
variance part is not really identified in this model
mat bb3 = e(b)

* modeling the variance of the residuals
eq vres : male female
gllamm weight male agemale female agefemale, nocons i(id) eqs( male
female agemale agefemale ) nrf(4) nip(8 8 8 8) from( bb3 ) skip s(
vres )
* same comment about the variance part

On Tue, Nov 24, 2009 at 2:53 AM, John Holmes
<[email protected]> wrote:
> Thanks for this Scott but I was hoping to be able to go further than
> the re-parameterisation.  The texts on LGM suggest that group
> modelling can be done so you are not simply estimating a single
> uniform effect on all coefficients from the grouping variable (as you
> say this is equivalent to including it as a main effect); but instead
> having two separate but simultaneously estimated models so that in
> practice each parameter has been given its own individual grouping
> variable effect.  I think this is possible in Mplus but was hoping to
> be able to do it in Stata as I don't have easy access to the former.
>
> 2009/11/23 Scott Baldwin <[email protected]>:
>> 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/
>>
>
>
>
> --
> John Holmes
>
> Research Associate
> Institute for Social Change
> University of Manchester
> 4th Floor Arthur Lewis Building
> Oxford Road
> Manchester
> M13 9PL
>
> Email: [email protected]
>
> *
> *   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/
>



-- 
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index