. use "fev1.dta"
. gen loght=log(ht)
. gen logbht=log(baseht)
. drop if (id==197)
(1 observation deleted)
. xtmixed logfev1 age loght baseage logbht || id: age, covariance(unstr) reml
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = 2283.5817
Iteration 1: log restricted-likelihood = 2283.9407
Iteration 2: log restricted-likelihood = 2283.9409
Iteration 3: log restricted-likelihood = 2283.9409
Computing standard errors:
Mixed-effects REML regression Number of obs = 1993
Group variable: id Number of groups = 299
Obs per group: min = 1
avg = 6.7
max = 12
Wald chi2(4) = 19515.72
Log restricted-likelihood = 2283.9409 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
logfev1 | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | .0235286 .0013953 16.86 0.000 .0207938 .0262634
loght | 2.237198 .0435372 51.39 0.000 2.151867 2.32253
baseage | -.0165088 .0074578 -2.21 0.027 -.0311259 -.0018917
logbht | .2182148 .1455209 1.50 0.134 -.0670009 .5034305
_cons | -.2883234 .0387168 -7.45 0.000 -.3642068 -.2124399
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured |
sd(age) | .0070784 .0006923 .0058436 .0085741
sd(_cons) | .1104856 .0087092 .0946691 .1289445
corr(age,_cons) | -.5530603 .0775124 -.6866806 -.383291
-----------------------------+------------------------------------------------
sd(Residual) | .0602379 .0011068 .0581071 .0624468
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(3) = 1606.43 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
Linear Mixed Effects Model (Random Intercept and Slope for Log Height)
. xtmixed logfev1 age loght baseage logbht || id: loght, covariance(unstr) reml
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = 2294.2958
Iteration 1: log restricted-likelihood = 2294.7353
Iteration 2: log restricted-likelihood = 2294.7366
Iteration 3: log restricted-likelihood = 2294.7366
Computing standard errors:
Mixed-effects REML regression Number of obs = 1993
Group variable: id Number of groups = 299
Obs per group: min = 1
avg = 6.7
max = 12
Wald chi2(4) = 16410.02
Log restricted-likelihood = 2294.7366 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
logfev1 | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | .0232695 .0012474 18.65 0.000 .0208247 .0257143
loght | 2.252336 .0461318 48.82 0.000 2.16192 2.342753
baseage | -.0162974 .0074391 -2.19 0.028 -.0308777 -.0017171
logbht | .1807988 .1454883 1.24 0.214 -.104353 .4659506
_cons | -.2846124 .0390149 -7.29 0.000 -.3610802 -.2081446
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured |
sd(loght) | .2617048 .0242124 .2183033 .3137352
sd(_cons) | .1153426 .0092436 .0985767 .1349601
corr(loght,_cons) | -.6145628 .0667231 -.7288942 -.466883
-----------------------------+------------------------------------------------
sd(Residual) | .0594427 .0010994 .0573264 .061637
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(3) = 1628.02 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
Linear Mixed Effects Model (Random Intercept and Slopes for Age and Log Height)
. xtmixed logfev1 age loght baseage logbht || id: age loght, covariance(unstr) reml
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = 2292.9683
Iteration 1: log restricted-likelihood = 2294.8588
Iteration 2: log restricted-likelihood = 2294.9495
Iteration 3: log restricted-likelihood = 2294.9496
Computing standard errors:
Mixed-effects REML regression Number of obs = 1993
Group variable: id Number of groups = 299
Obs per group: min = 1
avg = 6.7
max = 12
Wald chi2(4) = 16381.52
Log restricted-likelihood = 2294.9496 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
logfev1 | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | .0234444 .0012781 18.34 0.000 .0209394 .0259493
loght | 2.247566 .04692 47.90 0.000 2.155605 2.339528
baseage | -.0161017 .0074294 -2.17 0.030 -.030663 -.0015404
logbht | .1774342 .145365 1.22 0.222 -.1074759 .4623444
_cons | -.2856671 .039029 -7.32 0.000 -.3621626 -.2091716
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured |
sd(age) | .0034359 .0042289 .0003079 .0383437
sd(loght) | .2825643 .0723034 .1711233 .4665791
sd(_cons) | .1156211 .009244 .0988514 .1352358
corr(age,loght) | -.3731627 .5448813 -.9264608 .6903509
corr(age,_cons) | -.1647258 .4694849 -.804796 .6524759
corr(loght,_cons) | -.5090889 .1780755 -.774958 -.0901305
-----------------------------+------------------------------------------------
sd(Residual) | .0592925 .0011478 .0570849 .0615855
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(6) = 1628.45 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. use "fat.dta"
. gen time_0=max(time,0)
. xtmixed pbf time time_0 || id: time time_0, covariance(unstr) reml
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -3031.2068
Iteration 1: log restricted-likelihood = -3031.2007
Iteration 2: log restricted-likelihood = -3031.2007
Computing standard errors:
Mixed-effects REML regression Number of obs = 1049
Group variable: id Number of groups = 162
Obs per group: min = 3
avg = 6.5
max = 10
Wald chi2(2) = 537.62
Log restricted-likelihood = -3031.2007 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
pbf | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
time | .4171133 .1571569 2.65 0.008 .1090913 .7251352
time_0 | 2.047139 .2279683 8.98 0.000 1.600329 2.493948
_cons | 21.36138 .5645558 37.84 0.000 20.25487 22.46789
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured |
sd(time) | 1.277138 .1695448 .9845495 1.656677
sd(time_0) | 1.658219 .2905334 1.176263 2.337649
sd(_cons) | 6.778004 .4233863 5.996968 7.660761
corr(time,time_0) | -.8265875 .0577527 -.911212 -.6750216
corr(time,_cons) | .2918369 .1186305 .0463819 .5040574
corr(time_0,_cons) | -.5435916 .1050942 -.7170833 -.3066687
-----------------------------+------------------------------------------------
sd(Residual) | 3.07786 .0884235 2.909342 3.256139
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(6) = 1011.02 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
Linear Mixed Effects Model (Hybrid Model with Exponential Serial Correlation)
. xtmixed pbf time time_0 || id: , residuals(exponential, t(time)) variance reml
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -3014.4152
Iteration 1: log restricted-likelihood = -3012.1175
Iteration 2: log restricted-likelihood = -3009.8039
Iteration 3: log restricted-likelihood = -3009.7843
Iteration 4: log restricted-likelihood = -3009.7843
Computing standard errors:
Mixed-effects REML regression Number of obs = 1049
Group variable: id Number of groups = 162
Obs per group: min = 3
avg = 6.5
max = 10
Wald chi2(2) = 455.88
Log restricted-likelihood = -3009.7843 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
pbf | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
time | .2448002 .1428355 1.71 0.087 -.0351522 .5247526
time_0 | 2.15342 .2299133 9.37 0.000 1.702798 2.604042
_cons | 21.29795 .5390842 39.51 0.000 20.24136 22.35453
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Identity |
var(_cons) | 31.3703 4.290059 23.99453 41.01334
-----------------------------+------------------------------------------------
Residual: Exponential |
rho | .4917184 .0439881 .406589 .5773308
var(e) | 17.30156 1.456894 14.66929 20.40617
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(2) = 1053.85 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. use "cd4.dta"
. gen trt=0
. replace trt=1 if (group==4)
(1292 real changes made)
. gen week_16 = max(week - 16,0)
. gen w16=week_16 - week
. xtmixed logcd4 week week_16 1.trt#c.week 1.trt#c.week_16 ///
|| id: week week_16, covar(unstr) reml
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -5973.1792
Iteration 1: log restricted-likelihood = -5967.5953
Iteration 2: log restricted-likelihood = -5967.4826
Iteration 3: log restricted-likelihood = -5967.4826
Computing standard errors:
Mixed-effects REML regression Number of obs = 5036
Group variable: id Number of groups = 1309
Obs per group: min = 1
avg = 3.8
max = 9
Wald chi2(4) = 269.15
Log restricted-likelihood = -5967.4826 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
logcd4 | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
week | -.0073438 .0019868 -3.70 0.000 -.0112379 -.0034497
week_16 | -.0120392 .0031744 -3.79 0.000 -.018261 -.0058174
|
trt#c.week |
1 | .0268521 .0038472 6.98 0.000 .0193117 .0343924
|
trt#|
c.week_16 |
1 | -.0277377 .0061984 -4.47 0.000 -.0398863 -.0155891
|
_cons | 2.941459 .0256208 114.81 0.000 2.891243 2.991674
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured |
sd(week) | .0303839 .0026396 .0256268 .036024
sd(week_16) | .035219 .0056037 .0257836 .0481074
sd(_cons) | .7653389 .0227054 .7221062 .8111599
corr(week,week_16) | -.8584049 .0354259 -.9139693 -.7712424
corr(week,_cons) | .3119534 .0963349 .1130545 .4868139
corr(week_16,_cons) | -.4580848 .1441795 -.6923825 -.1363964
-----------------------------+------------------------------------------------
sd(Residual) | .5533193 .0091034 .5357616 .5714525
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(6) = 3046.55 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
. xtmixed logcd4 age sex week week_16 1.trt#c.week 1.trt#c.week_16 ///
|| id: week week_16, covar(unstr) reml
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -5973.8681
Iteration 1: log restricted-likelihood = -5968.2941
Iteration 2: log restricted-likelihood = -5968.1828
Iteration 3: log restricted-likelihood = -5968.1828
Computing standard errors:
Mixed-effects REML regression Number of obs = 5036
Group variable: id Number of groups = 1309
Obs per group: min = 1
avg = 3.8
max = 9
Wald chi2(6) = 280.68
Log restricted-likelihood = -5968.1828 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
logcd4 | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age | .0099963 .0030156 3.31 0.001 .0040857 .0159068
sex | -.0926865 .075371 -1.23 0.219 -.2404109 .0550379
week | -.0072961 .0019863 -3.67 0.000 -.0111893 -.003403
week_16 | -.0120626 .0031742 -3.80 0.000 -.0182839 -.0058412
|
trt#c.week |
1 | .0267911 .0038433 6.97 0.000 .0192583 .0343239
|
trt#|
c.week_16 |
1 | -.0277246 .0061966 -4.47 0.000 -.0398697 -.0155795
|
_cons | 2.645545 .128002 20.67 0.000 2.394666 2.896424
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured |
sd(week) | .0303907 .0026394 .0256339 .0360303
sd(week_16) | .03523 .0056017 .0257969 .0481124
sd(_cons) | .762525 .0227028 .7193017 .8083457
corr(week,week_16) | -.8584173 .0354138 -.9139657 -.7712896
corr(week,_cons) | .3040208 .0960966 .1060167 .4788347
corr(week_16,_cons) | -.4519524 .1437362 -.6864356 -.1323376
-----------------------------+------------------------------------------------
sd(Residual) | .5533322 .0091033 .5357747 .5714651
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(6) = 3017.41 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference.
Linear Mixed Effects Model (Random Intercept and Slope): Predicted Means
. predict yhat, fitted
. list id trt week logcd4 yhat
+---------------------------------------------+
| id trt week logcd4 yhat |
|---------------------------------------------|
1. | 1 0 0 3.135494 3.064093 |
2. | 1 0 7.5714 3.044523 3.070353 |
3. | 1 0 15.5714 2.772589 3.076968 |
4. | 1 0 23.5714 2.833213 2.992445 |
5. | 1 0 32.5714 3.218876 2.891552 |
|---------------------------------------------|
6. | 1 0 40 3.044523 2.808275 |
7. | 2 1 0 3.068053 3.317106 |
8. | 2 1 8 3.89182 3.552587 |
9. | 2 1 16 3.970292 3.788067 |
10. | 2 1 23 3.610918 3.608966 |
|---------------------------------------------|
11. | 2 1 30.7143 3.332205 3.411588 |
12. | 2 1 39 3.091043 3.19959 |
13. | 3 0 0 3.73767 3.536859 |
14. | 4 0 0 4.119037 3.912174 |
15. | 4 0 7.1429 4.110874 3.970654 |
|---------------------------------------------|
16. | 4 0 16.1429 4.70953 4.037921 |
17. | 4 0 32.4286 2.833213 3.439988 |
18. | 5 0 0 3.583519 3.438741 |
19. | 5 0 8 3.433987 3.451443 |
20. | 5 0 16 3.433987 3.464145 |
|---------------------------------------------|
21. | 5 0 24 3.713572 3.237965 |
22. | 5 0 32 3.044523 3.011784 |
23. | 5 0 40 2.397895 2.785604 |
24. | 6 0 0 2.397895 2.560917 |
25. | 6 0 7.2857 2.397895 2.476918 |
|---------------------------------------------|
26. | 6 0 15 2.397895 2.387976 |
27. | 6 0 24 3.044523 2.248687 |
28. | 6 0 31.4286 0 2.130051 |
29. | 6 0 35.4286 3.433987 2.066171 |
30. | 7 0 0 2.397895 3.042412 |
|---------------------------------------------|
31. | 7 0 9 3.713572 3.113958 |
32. | 8 0 0 2.772589 2.789408 |
33. | 8 0 7.7143 2.397895 2.750947 |
34. | 8 0 15.5714 3.044523 2.711774 |
35. | 8 0 29.5714 2.397895 2.457348 |
|---------------------------------------------|
36. | 9 0 0 3.258096 3.159818 |
37. | 10 0 0 2.079442 2.371482 |
38. | 11 0 0 2.772589 2.855485 |
39. | 11 0 4.1429 3.044523 2.793338 |
40. | 11 0 17 2.397895 2.596411 |
|---------------------------------------------|
41. | 11 0 27 2.397895 2.40579 |
42. | 12 1 0 3.828641 3.491254 |
43. | 12 1 16.1429 3.931826 3.910416 |
44. | 12 1 33 3.433987 3.466867 |
45. | 13 1 0 0 .7076196 |
|---------------------------------------------|
46. | 13 1 17 0 .2614039 |
47. | 13 1 34.8571 0 .1697235 |
48. | 14 0 0 1.791759 2.629654 |
49. | 14 0 7 3.433987 2.616971 |
50. | 14 0 11.7143 2.397895 2.60843 |
|---------------------------------------------|
51. | 14 0 30 2.397895 2.383949 |
52. | 15 0 0 3.258096 3.620535 |
53. | 15 0 17.1429 4.26268 4.117562 |
54. | 15 0 35.8571 4.394449 3.873465 |
55. | 16 0 0 3.713572 3.200243 |
|---------------------------------------------|
56. | 16 0 7.2857 2.397895 3.174659 |
57. | 16 0 15.8571 3.433987 3.14456 |
58. | 16 0 25.2857 3.044523 2.954712 |
<output deleted>
Linear Mixed Effects Model (Random Intercept and Slope): Empirical BLUPs
. predict blup*, reffects
. describe blup1 blup2 blup3
storage display value
variable name type format label variable label
------------------------------------------------------------------------------------
blup1 float %9.0g BLUP r.e. for id: week
blup2 float %9.0g BLUP r.e. for id: week_16
blup3 float %9.0g BLUP r.e. for id: _cons
. list id blup1 blup2 blup3
+------------------------------------------+
| id blup1 blup2 blup3 |
|------------------------------------------|
1. | 1 .008123 .0000255 .1470983 |
2. | 1 .008123 .0000255 .1470983 |
3. | 1 .008123 .0000255 .1470983 |
4. | 1 .008123 .0000255 .1470983 |
5. | 1 .008123 .0000255 .1470983 |
|------------------------------------------|
6. | 1 .008123 .0000255 .1470983 |
7. | 2 .0099401 -.0152338 .2859578 |
8. | 2 .0099401 -.0152338 .2859578 |
9. | 2 .0099401 -.0152338 .2859578 |
10. | 2 .0099401 -.0152338 .2859578 |
|------------------------------------------|
11. | 2 .0099401 -.0152338 .2859578 |
12. | 2 .0099401 -.0152338 .2859578 |
13. | 3 .0046208 -.0079629 .3813492 |
14. | 4 .0154832 -.0328397 .9934821 |
15. | 4 .0154832 -.0328397 .9934821 |
|------------------------------------------|
16. | 4 .0154832 -.0328397 .9934821 |
17. | 4 .0154832 -.0328397 .9934821 |
18. | 5 .0088839 -.0177977 .5265357 |
19. | 5 .0088839 -.0177977 .5265357 |
20. | 5 .0088839 -.0177977 .5265357 |
|------------------------------------------|
21. | 5 .0088839 -.0177977 .5265357 |
22. | 5 .0088839 -.0177977 .5265357 |
23. | 5 .0088839 -.0177977 .5265357 |
24. | 6 -.0042332 .0076219 -.3757553 |
25. | 6 -.0042332 .0076219 -.3757553 |
|------------------------------------------|
26. | 6 -.0042332 .0076219 -.3757553 |
27. | 6 -.0042332 .0076219 -.3757553 |
28. | 6 -.0042332 .0076219 -.3757553 |
29. | 6 -.0042332 .0076219 -.3757553 |
30. | 7 .0152457 -.0144187 .0389055 |
|------------------------------------------|
31. | 7 .0152457 -.0144187 .0389055 |
32. | 8 .0023105 -.0015416 -.1353048 |
33. | 8 .0023105 -.0015416 -.1353048 |
34. | 8 .0023105 -.0015416 -.1353048 |
35. | 8 .0023105 -.0015416 -.1353048 |
|------------------------------------------|
36. | 9 .0022614 -.0038971 .1866361 |
37. | 10 -.00672 .0115806 -.5545992 |
38. | 11 -.0077046 .0080014 -.1196947 |
39. | 11 -.0077046 .0080014 -.1196947 |
40. | 11 -.0077046 .0080014 -.1196947 |
|------------------------------------------|
41. | 11 -.0077046 .0080014 -.1196947 |
42. | 12 .0069377 -.0129577 .6239603 |
43. | 12 .0069377 -.0129577 .6239603 |
44. | 12 .0069377 -.0129577 .6239603 |
45. | 13 -.0470626 .0622207 -2.263647 |
|------------------------------------------|
46. | 13 -.0470626 .0622207 -2.263647 |
47. | 13 -.0470626 .0622207 -2.263647 |
48. | 14 .0054843 -.0016053 -.336247 |
49. | 14 .0054843 -.0016053 -.336247 |
50. | 14 .0054843 -.0016053 -.336247 |
|------------------------------------------|
51. | 14 .0054843 -.0016053 -.336247 |
52. | 15 .039292 -.0329767 .6469707 |
53. | 15 .039292 -.0329767 .6469707 |
54. | 15 .039292 -.0329767 .6469707 |
55. | 16 .0037846 -.0048169 .2144827 |
|------------------------------------------|
56. | 16 .0037846 -.0048169 .2144827 |
57. | 16 .0037846 -.0048169 .2144827 |
58. | 16 .0037846 -.0048169 .2144827 |
59. | 17 -.0086504 .0097754 -.1088617 |
60. | 17 -.0086504 .0097754 -.1088617 |
|------------------------------------------|
61. | 17 -.0086504 .0097754 -.1088617 |
62. | 18 .0145515 -.01669 .6506844 |
63. | 18 .0145515 -.01669 .6506844 |
64. | 18 .0145515 -.01669 .6506844 |
65. | 19 -.0019165 .0033027 -.1581665 |
|------------------------------------------|
66. | 20 -.0095998 .0165434 -.7922711 |
<output deleted>