Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: Latent Growth model and mixed effects random slopes model - equivalent ?

 From W Robert Long To "statalist@hsphsun2.harvard.edu" Subject st: Latent Growth model and mixed effects random slopes model - equivalent ? Date Sun, 28 Apr 2013 23:19:40 +0100

```Dear all

```
What am I missing here ? I'm looking at latent growth models in -sem- and mixed effects / multilevel models in -xtmixed- which I thought should be equivalent.
```
```
For a random intercepts model, everything agrees 100%, but with random slopes, the variances of the random effects differ.
```
use http://www.stata-press.com/data/r12/pig.dta, clear

* first a random intercepts model:
xtmixed weight week ||id: , var

------------------------------------------------------------------------------
```
weight | Coef. Std. Err. z P>|z| [95% Conf. Interval]
```-------------+----------------------------------------------------------------
week |   6.209896   .0390124   159.18   0.000 6.133433    6.286359
_cons |   19.35561   .5974059    32.40   0.000 18.18472    20.52651
------------------------------------------------------------------------------

------------------------------------------------------------------------------
```
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
```-----------------------------+------------------------------------------------
id: Identity                 |
var(_cons) |   14.81751   3.124226 9.801716    22.40002
-----------------------------+------------------------------------------------
var(Residual) |   4.383264   .3163348 3.805112     5.04926
------------------------------------------------------------------------------

* now with -sem-
reshape wide weight, i(id) j(week)

sem (Intercept@1 Slope@0 -> weight1) ///
(Intercept@1 Slope@1 -> weight2) ///
(Intercept@1 Slope@2 -> weight3) ///
(Intercept@1 Slope@3 -> weight4) ///
(Intercept@1 Slope@4 -> weight5) ///
(Intercept@1 Slope@5 -> weight6) ///
(Intercept@1 Slope@6 -> weight7) ///
(Intercept@1 Slope@7 -> weight8) ///
(Intercept@1 Slope@8 -> weight9) ///
,nocons means(Intercept Slope) ///
```
cov(Slope@0 e.weight1@fix1 e.weight2@fix1 e.weight3@fix1 e.weight4@fix1 /// e.weight5@fix1 e.weight6@fix1 e.weight7@fix1 e.weight8@fix1 e.weight9@fix1 ///
```    Intercept*Slope@0)

--------------+----------------------------------------------------------------
Mean          |
Intercept |   25.56551    .585829    43.64   0.000 24.41731    26.71371
Slope |   6.209896   .0390124   159.18   0.000 6.133433    6.286359
--------------+----------------------------------------------------------------
Variance      |
e.weight1 |   4.383264   .3163348 3.805112    5.049261
e.weight2 |   4.383264   .3163348 3.805112    5.049261
e.weight3 |   4.383264   .3163348 3.805112    5.049261
e.weight4 |   4.383264   .3163348 3.805112    5.049261
e.weight5 |   4.383264   .3163348 3.805112    5.049261
e.weight6 |   4.383264   .3163348 3.805112    5.049261
e.weight7 |   4.383264   .3163348 3.805112    5.049261
e.weight8 |   4.383264   .3163348 3.805112    5.049261
e.weight9 |   4.383264   .3163348 3.805112    5.049261
Intercept |   14.81749    3.12422 9.801705    22.39999
Slope |          0  (constrained)
-------------------------------------------------------------------------------

* so. -xtmixed- and -sem- agree 100% with a random intercepts model

*now with random slopes....

use http://www.stata-press.com/data/r12/pig.dta, clear
xtmixed weight week ||id:week , var

------------------------------------------------------------------------------
```
weight | Coef. Std. Err. z P>|z| [95% Conf. Interval]
```-------------+----------------------------------------------------------------
week |   6.209896   .0906819    68.48   0.000 6.032163    6.387629
_cons |   19.35561   .3979159    48.64   0.000 18.57571    20.13551
------------------------------------------------------------------------------

------------------------------------------------------------------------------
```
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
```-----------------------------+------------------------------------------------
id: Independent              |
var(week) |   .3680668   .0801181 .2402389    .5639103
var(_cons) |   6.756364   1.543503 4.317721    10.57235
-----------------------------+------------------------------------------------
var(Residual) |   1.598811   .1233988 1.374358     1.85992
------------------------------------------------------------------------------

* now with -sem-
sem (Intercept@1 Slope@0 -> weight1) ///
(Intercept@1 Slope@1 -> weight2) ///
(Intercept@1 Slope@2 -> weight3) ///
(Intercept@1 Slope@3 -> weight4) ///
(Intercept@1 Slope@4 -> weight5) ///
(Intercept@1 Slope@5 -> weight6) ///
(Intercept@1 Slope@6 -> weight7) ///
(Intercept@1 Slope@7 -> weight8) ///
(Intercept@1 Slope@8 -> weight9) ///
,nocons means(Intercept Slope) ///
cov(e.weight1@fix1 e.weight2@fix1 e.weight3@fix1 e.weight4@fix1 ///
```
e.weight5@fix1 e.weight6@fix1 e.weight7@fix1 e.weight8@fix1 e.weight9@fix1 ///
```    Intercept*Slope@0)

--------------+----------------------------------------------------------------
Mean          |
Intercept |   25.56551   .4016519    63.65   0.000 24.77829    26.35273
Slope |   6.209896   .0919231    67.56   0.000 6.02973    6.390062
--------------+----------------------------------------------------------------
Variance      |
e.weight1 |   1.592648   .1225009 1.369772    1.851787
e.weight2 |   1.592648   .1225009 1.369772    1.851787
e.weight3 |   1.592648   .1225009 1.369772    1.851787
e.weight4 |   1.592648   .1225009 1.369772    1.851787
e.weight5 |   1.592648   .1225009 1.369772    1.851787
e.weight6 |   1.592648   .1225009 1.369772    1.851787
e.weight7 |   1.592648   .1225009 1.369772    1.851787
e.weight8 |   1.592648   .1225009 1.369772    1.851787
e.weight9 |   1.592648   .1225009 1.369772    1.851787
Intercept |   7.141896   1.575664 4.634674    11.00545
Slope |   .3790488   .0825236 .2473877    .5807808
--------------+----------------------------------------------------------------
Covariance    |
Intercept   |
Slope |          0  (constrained)
-------------------------------------------------------------------------------

* The random effects are different.

* now with correlated random effects
------------------------------------------------------------------------------
```
weight | Coef. Std. Err. z P>|z| [95% Conf. Interval]
```-------------+----------------------------------------------------------------
week |   6.209896   .0910745    68.18   0.000 6.031393    6.388399
_cons |   19.35561   .3996387    48.43   0.000 18.57234    20.13889
------------------------------------------------------------------------------

------------------------------------------------------------------------------
```
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
```-----------------------------+------------------------------------------------
id: Unstructured             |
var(week) |   .3715251   .0812958 .2419532     .570486
var(_cons) |   6.823363   1.566194 4.351297    10.69986
cov(week,_cons) |  -.0984378   .2545767 -.5973991    .4005234
-----------------------------+------------------------------------------------
var(Residual) |   1.596829    .123198 1.372735    1.857505
------------------------------------------------------------------------------

* and with -sem-
reshape wide weight, i(id) j(week)

sem (Intercept@1 Slope@0 -> weight1) ///
(Intercept@1 Slope@1 -> weight2) ///
(Intercept@1 Slope@2 -> weight3) ///
(Intercept@1 Slope@3 -> weight4) ///
(Intercept@1 Slope@4 -> weight5) ///
(Intercept@1 Slope@5 -> weight6) ///
(Intercept@1 Slope@6 -> weight7) ///
(Intercept@1 Slope@7 -> weight8) ///
(Intercept@1 Slope@8 -> weight9) ///
,nocons means(Intercept Slope) ///
cov(e.weight1@fix1 e.weight2@fix1 e.weight3@fix1 e.weight4@fix1 ///
```
e.weight5@fix1 e.weight6@fix1 e.weight7@fix1 e.weight8@fix1 e.weight9@fix1)
```
--------------+----------------------------------------------------------------
Mean          |
Intercept |   25.56551   .3979436    64.24   0.000 24.78555    26.34546
Slope |   6.209896   .0910744    68.18   0.000 6.031393    6.388398
--------------+----------------------------------------------------------------
Variance      |
e.weight1 |    1.59683   .1231981 1.372736    1.857506
e.weight2 |    1.59683   .1231981 1.372736    1.857506
e.weight3 |    1.59683   .1231981 1.372736    1.857506
e.weight4 |    1.59683   .1231981 1.372736    1.857506
e.weight5 |    1.59683   .1231981 1.372736    1.857506
e.weight6 |    1.59683   .1231981 1.372736    1.857506
e.weight7 |    1.59683   .1231981 1.372736    1.857506
e.weight8 |    1.59683   .1231981 1.372736    1.857506
e.weight9 |    1.59683   .1231981 1.372736    1.857506
Intercept |   6.997989    1.55229 4.530646    10.80902
Slope |   .3715242   .0812954 .2419528    .5704842
--------------+----------------------------------------------------------------
Covariance    |
Intercept   |
```
Slope | .2730897 .2523778 1.08 0.279 -.2215616 .767741
```-------------------------------------------------------------------------------

```
* here the difference is even more marked - different signs for the covariance of the intercept and slope. While not statistically significant in this example, in the data I am working with there is significant positive covariance: 0.38 (0.26 - 0.51) from -sem- but a negative significant covariance from -xtmixed- : -0.18 (-0.32 -0.04)
```
What am I missing here ?

Many thanks
Robert Long

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```