. use "smoking.dta"
(771 observations read)
. xtmixed fev1 1.smoker c.time 1.smoker#c.time || id: , ///
noconst residuals(unstructured, t(time)) reml
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -659.26555 (not concave)
Iteration 1: log restricted-likelihood = -222.6972
Iteration 2: log restricted-likelihood = -161.53664
Iteration 3: log restricted-likelihood = -136.44052
Iteration 4: log restricted-likelihood = -133.29021
Iteration 5: log restricted-likelihood = -133.02603
Iteration 6: log restricted-likelihood = -133.02532
Iteration 7: log restricted-likelihood = -133.02532
Computing standard errors:
Mixed-effects REML regression Number of obs = 771
Group variable: id Number of groups = 133
Obs per group: min = 1
avg = 5.8
max = 7
Wald chi2(3) = 607.67
Log restricted-likelihood = -133.02532 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
fev1 | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.smoker | -.2616996 .1151 -2.27 0.023 -.4872913 -.0361078
time | -.0332243 .0030663 -10.84 0.000 -.0392342 -.0272144
|
smoker#|
c.time |
1 | -.0049984 .0035254 -1.42 0.156 -.011908 .0019112
|
_cons | 3.507313 .1003784 34.94 0.000 3.310575 3.704051
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: (empty) |
-----------------------------+------------------------------------------------
Residual: Unstructured |
sd(e0) | .5959408 .039439 .5234452 .678477
sd(e3) | .5828185 .0368568 .514878 .6597241
sd(e6) | .5667042 .0356325 .5009976 .6410283
sd(e9) | .5691593 .0364624 .5019989 .6453048
sd(e12) | .5594311 .0352272 .4944776 .6329167
sd(e15) | .5768604 .0376883 .5075266 .655666
sd(e19) | .5481524 .0357412 .4823924 .6228768
corr(e0,e3) | .8628108 .0247147 .8057155 .904019
corr(e0,e6) | .8457978 .0275915 .7822737 .891912
corr(e0,e9) | .8378473 .0286658 .7720474 .8858768
corr(e0,e12) | .8553072 .0258347 .7957719 .8984684
corr(e0,e15) | .8389877 .0329113 .7615506 .8928072
corr(e0,e19) | .8308471 .0309197 .7595637 .8824091
corr(e3,e6) | .887808 .0201635 .8410899 .9213779
corr(e3,e9) | .8329119 .029272 .7658603 .8820443
corr(e3,e12) | .8619242 .0239013 .8070688 .9020284
corr(e3,e15) | .8740405 .0225603 .821894 .9116596
corr(e3,e19) | .8237995 .0301766 .7549978 .8746602
corr(e6,e9) | .8333251 .0284496 .7684131 .8812644
corr(e6,e12) | .8900114 .0197849 .8441506 .922941
corr(e6,e15) | .8677585 .0235932 .8133048 .9071429
corr(e6,e19) | .8336594 .0294319 .7661302 .8829817
corr(e9,e12) | .885758 .0199613 .8397366 .9191447
corr(e9,e15) | .8762306 .0216853 .8262728 .9125104
corr(e9,e19) | .8396783 .0283297 .7746383 .8871413
corr(e12,e15) | .9320125 .0135812 .8997387 .9541482
corr(e12,e19) | .8576585 .0252635 .7994772 .8998977
corr(e15,e19) | .892769 .0197004 .8469221 .9254391
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(27) = 1052.48 Prob > chi2 = 0.0000
Note: The reported degrees of freedom assumes the null hypothesis is not on the
boundary of the parameter space. If this is not true, then the reported test is
conservative.
Linear Trend Model (ML Estimation)
. xtmixed fev1 1.smoker c.time 1.smoker#c.time || id: , noconst ///
residuals(unstructured, t(time))
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log likelihood = -645.39358 (not concave)
Iteration 1: log likelihood = -210.49385
Iteration 2: log likelihood = -208.15603 (not concave)
Iteration 3: log likelihood = -162.1537 (not concave)
Iteration 4: log likelihood = -127.84853
Iteration 5: log likelihood = -120.88432
Iteration 6: log likelihood = -119.24672
Iteration 7: log likelihood = -119.23047
Iteration 8: log likelihood = -119.23046
Iteration 9: log likelihood = -119.23046
Computing standard errors:
Mixed-effects ML regression Number of obs = 771
Group variable: id Number of groups = 133
Obs per group: min = 1
avg = 5.8
max = 7
Wald chi2(3) = 617.75
Log likelihood = -119.23046 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
fev1 | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.smoker | -.2617388 .1142359 -2.29 0.022 -.485637 -.0378405
time | -.0332263 .003042 -10.92 0.000 -.0391884 -.0272641
|
smoker#|
c.time |
1 | -.0050053 .0034973 -1.43 0.152 -.0118598 .0018493
|
_cons | 3.50742 .0996254 35.21 0.000 3.312157 3.702682
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: (empty) |
-----------------------------+------------------------------------------------
Residual: Unstructured |
sd(e0) | .5919617 .0389915 .5202673 .6735359
sd(e3) | .5789156 .036411 .5117746 .6548649
sd(e6) | .5628814 .0351886 .4979707 .6362531
sd(e9) | .5653843 .0360434 .4989758 .6406312
sd(e12) | .555653 .0347946 .4914757 .6282107
sd(e15) | .5731412 .0372955 .5045127 .6511052
sd(e19) | .5439858 .0352392 .4791229 .6176297
corr(e0,e3) | .8610213 .024942 .8034508 .9026394
corr(e0,e6) | .8440068 .0277964 .7800691 .8905002
corr(e0,e9) | .8362326 .0288426 .7700804 .8845926
corr(e0,e12) | .8542686 .0259267 .7945642 .8976115
corr(e0,e15) | .8386578 .0329311 .7611986 .892525
corr(e0,e19) | .8309296 .0307681 .7600454 .8822747
corr(e3,e6) | .8863249 .0203588 .8391913 .9202426
corr(e3,e9) | .8309423 .0295061 .7634115 .8805036
corr(e3,e12) | .8606053 .0240416 .8054691 .9009713
corr(e3,e15) | .8733229 .0226091 .8210989 .9110465
corr(e3,e19) | .8230869 .0301631 .7543687 .8739615
corr(e6,e9) | .8311253 .0287065 .7656864 .8795354
corr(e6,e12) | .8888206 .019931 .8426548 .9220144
corr(e6,e15) | .8665699 .0237259 .8118484 .9062002
corr(e6,e19) | .8324892 .0295209 .7648086 .8819958
corr(e9,e12) | .8842779 .0201471 .8378642 .9179978
corr(e9,e15) | .874868 .0218493 .8245692 .9114453
corr(e9,e19) | .8381261 .0284945 .7727609 .8858992
corr(e12,e15) | .9311458 .0137308 .8985317 .9535336
corr(e12,e19) | .8559657 .0254601 .7973831 .8985661
corr(e15,e19) | .8914829 .019863 .8452951 .9244458
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(27) = 1052.33 Prob > chi2 = 0.0000
Note: The reported degrees of freedom assumes the null hypothesis is not on the
boundary of the parameter space. If this is not true, then the reported test is
conservative.
Quadratic Trend Model (ML Estimation)
. xtmixed fev1 1.smoker c.time##c.time 1.smoker#(c.time##c.time) || id: , ///
noconst residuals(unstructured, t(time))
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log likelihood = -645.04414 (not concave)
Iteration 1: log likelihood = -210.20495
Iteration 2: log likelihood = -153.11538
Iteration 3: log likelihood = -121.4061
Iteration 4: log likelihood = -118.64164
Iteration 5: log likelihood = -118.59129
Iteration 6: log likelihood = -118.5912
Iteration 7: log likelihood = -118.5912
Computing standard errors:
Mixed-effects ML regression Number of obs = 771
Group variable: id Number of groups = 133
Obs per group: min = 1
avg = 5.8
max = 7
Wald chi2(5) = 617.54
Log likelihood = -118.5912 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
fev1 | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.smoker | -.2977847 .1183755 -2.52 0.012 -.5297965 -.065773
time | -.0413393 .0100488 -4.11 0.000 -.0610346 -.021644
|
c.time#|
c.time | .0004106 .0004852 0.85 0.397 -.0005403 .0013615
|
smoker#|
c.time |
1 | .00755 .0114822 0.66 0.511 -.0149548 .0300547
|
smoker#|
c.time#|
c.time |
1 | -.0006422 .0005591 -1.15 0.251 -.0017381 .0004537
|
_cons | 3.531199 .1034022 34.15 0.000 3.328534 3.733863
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: (empty) |
-----------------------------+------------------------------------------------
Residual: Unstructured |
sd(e0) | .5914796 .0388846 .5199728 .6728199
sd(e3) | .5783574 .0363607 .5113075 .6541999
sd(e6) | .5619766 .0350744 .4972704 .6351026
sd(e9) | .5652513 .0360951 .4987543 .6406142
sd(e12) | .5555015 .0347735 .4913617 .6280137
sd(e15) | .5732584 .0373328 .5045646 .6513044
sd(e19) | .543566 .0351889 .4787933 .6171014
corr(e0,e3) | .860158 .025138 .8021264 .9020949
corr(e0,e6) | .847731 .0274739 .7843756 .8935814
corr(e0,e9) | .8336349 .0295184 .7658776 .8830809
corr(e0,e12) | .8549655 .0258526 .7954075 .8981692
corr(e0,e15) | .8357665 .0337025 .7564526 .890856
corr(e0,e19) | .8314704 .0306323 .7609075 .8825966
corr(e3,e6) | .8876317 .0201856 .8408673 .9212414
corr(e3,e9) | .8299552 .0297678 .7618028 .8799369
corr(e3,e12) | .8613552 .0239414 .8064328 .9015433
corr(e3,e15) | .873009 .0226647 .8206589 .9108264
corr(e3,e19) | .8222123 .0303305 .7531145 .8733681
corr(e6,e9) | .8303305 .0288483 .7645729 .8789808
corr(e6,e12) | .8879501 .0201156 .8413509 .9214458
corr(e6,e15) | .8670327 .0236408 .8125054 .9065202
corr(e6,e19) | .835163 .0290713 .7684814 .8838998
corr(e9,e12) | .8842953 .0201423 .8378929 .9180077
corr(e9,e15) | .8743164 .0219771 .8237153 .9111009
corr(e9,e19) | .8356393 .0292867 .7683506 .8846571
corr(e12,e15) | .9318293 .013622 .8994575 .9540305
corr(e12,e19) | .8565223 .0253863 .7980964 .898991
corr(e15,e19) | .8905087 .0200509 .843886 .9237833
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(27) = 1052.91 Prob > chi2 = 0.0000
Note: The reported degrees of freedom assumes the null hypothesis is not on the
boundary of the parameter space. If this is not true, then the reported test is
conservative.
. use "tlc.dta"
. reshape long y, i(id) j(time)
(note: j = 0 1 4 6)
Data wide -> long
-----------------------------------------------------------------------------
Number of obs. 100 -> 400
Number of variables 7 -> 5
j variable (4 values) -> time
xij variables:
y0 y1 ... y6 -> y
-----------------------------------------------------------------------------
. gen time_1=max(time-1, 0)
. xtmixed y c.time c.time_1 1.trt#c.time 1.trt#c.time_1 || id: , ///
noconst residuals(unstructured, t(time)) reml
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -1321.7656 (not concave)
Iteration 1: log restricted-likelihood = -1247.7923
Iteration 2: log restricted-likelihood = -1235.3283
Iteration 3: log restricted-likelihood = -1220.0722
Iteration 4: log restricted-likelihood = -1218.7419
Iteration 5: log restricted-likelihood = -1218.7262
Iteration 6: log restricted-likelihood = -1218.7262
Computing standard errors:
Mixed-effects REML regression Number of obs = 400
Group variable: id Number of groups = 100
Obs per group: min = 4
avg = 4.0
max = 4
Wald chi2(4) = 285.30
Log restricted-likelihood = -1218.7262 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
time | -1.629603 .7817556 -2.08 0.037 -3.161816 -.0973901
time_1 | 1.430495 .8777538 1.63 0.103 -.289871 3.150861
|
trt#c.time |
1 | -11.25 1.092447 -10.30 0.000 -13.39116 -9.108842
|
trt#c.time_1 |
1 | 12.58226 1.227847 10.25 0.000 10.17573 14.9888
|
_cons | 26.34221 .4991175 52.78 0.000 25.36396 27.32046
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: (empty) |
-----------------------------+------------------------------------------------
Residual: Unstructured |
sd(e0) | 4.999233 .3553283 4.349136 5.746506
sd(e1) | 6.648487 .4736068 5.782122 7.644664
sd(e4) | 6.92402 .4981448 6.013386 7.972555
sd(e6) | 7.71917 .5567123 6.701643 8.89119
corr(e0,e1) | .5693051 .0680191 .4212831 .6877835
corr(e0,e4) | .5597697 .0696783 .408335 .6812185
corr(e0,e6) | .5735463 .0678934 .4255836 .6916397
corr(e1,e4) | .7676784 .0420108 .6718727 .8382179
corr(e1,e6) | .5760139 .0682007 .4271723 .6944607
corr(e4,e6) | .5527423 .070034 .4008575 .675055
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(9) = 206.08 Prob > chi2 = 0.0000
Note: The reported degrees of freedom assumes the null hypothesis is not on the
boundary of the parameter space. If this is not true, then the reported test is
conservative.