. use "tlc.dta"
. gen baseline = y0
. 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 change = y - baseline
. gen t1=1.time
. gen t4=4.time
. gen t6=6.time
. xtmixed y t1 t4 t6 1.trt#(c.t1 c.t4 c.t6) || id: , noconst ///
residuals(unstructured, t(time)) reml
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -1314.3479 (not concave)
Iteration 1: log restricted-likelihood = -1242.5977
Iteration 2: log restricted-likelihood = -1232.4333
Iteration 3: log restricted-likelihood = -1212.0086
Iteration 4: log restricted-likelihood = -1209.0474
Iteration 5: log restricted-likelihood = -1208.9948
Iteration 6: log restricted-likelihood = -1208.9948
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(6) = 296.51
Log restricted-likelihood = -1208.9948 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
t1 | -1.644501 .7824025 -2.10 0.036 -3.177981 -.1110198
t4 | -2.231356 .8073858 -2.76 0.006 -3.813803 -.6489084
t6 | -2.642064 .8864596 -2.98 0.003 -4.379493 -.9046351
|
trt#c.t1 |
1 | -11.341 1.093118 -10.37 0.000 -13.48347 -9.198527
|
trt#c.t4 |
1 | -8.765289 1.131264 -7.75 0.000 -10.98253 -6.548052
|
trt#c.t6 |
1 | -3.119872 1.250775 -2.49 0.013 -5.571346 -.6683972
|
_cons | 26.406 .49989 52.82 0.000 25.42623 27.38577
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: (empty) |
-----------------------------+------------------------------------------------
Residual: Unstructured |
sd(e0) | 4.9989 .3552555 4.348929 5.746012
sd(e1) | 6.649058 .4737002 5.782529 7.64544
sd(e4) | 6.872662 .489636 5.976983 7.902564
sd(e6) | 7.646416 .5447313 6.649948 8.7922
corr(e0,e1) | .5694734 .0679828 .4215286 .6878887
corr(e0,e4) | .5680163 .0681493 .4197565 .686752
corr(e0,e6) | .575384 .067303 .4287286 .6924937
corr(e1,e4) | .7745661 .0403532 .6825851 .8423895
corr(e1,e6) | .5805742 .0668605 .4346822 .6967734
corr(e4,e6) | .5795825 .0669768 .4334686 .6960039
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(9) = 210.71 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.
. test 1.trt#c.t1 1.trt#c.t4 1.trt#c.t6
( 1) [y]1.trt#c.t1 = 0
( 2) [y]1.trt#c.t4 = 0
( 3) [y]1.trt#c.t6 = 0
chi2( 3) = 111.94
Prob > chi2 = 0.0000
Analysis of Response Profiles of Changes in Response from Baseline
. drop if time==0
(100 observations deleted)
. xtmixed change i.trt##i.time || id: , noconst ///
residuals(unstructured, t(time)) reml
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -950.18241
Iteration 1: log restricted-likelihood = -928.1055 (backed up)
Iteration 2: log restricted-likelihood = -916.24057
Iteration 3: log restricted-likelihood = -909.5036
Iteration 4: log restricted-likelihood = -909.45736
Iteration 5: log restricted-likelihood = -909.45729
Computing standard errors:
Mixed-effects REML regression Number of obs = 300
Group variable: id Number of groups = 100
Obs per group: min = 3
avg = 3.0
max = 3
Wald chi2(5) = 129.99
Log restricted-likelihood = -909.45729 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
change | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
1.trt | -11.406 1.11994 -10.18 0.000 -13.60104 -9.210958
|
time |
4 | -.5899999 .6427015 -0.92 0.359 -1.849672 .6696719
6 | -1.014 .93431 -1.09 0.278 -2.845214 .8172139
|
trt#time |
1 4 | 2.582 .9089172 2.84 0.005 .800555 4.363445
1 6 | 8.254 1.321314 6.25 0.000 5.664273 10.84373
|
_cons | -1.612 .7919171 -2.04 0.042 -3.164129 -.0598711
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: (empty) |
-----------------------------+------------------------------------------------
Residual: Unstructured |
sd(e1) | 5.599699 .3999787 4.868157 6.441171
sd(e4) | 5.762338 .4115954 5.009549 6.628249
sd(e6) | 6.282794 .4487709 5.462013 7.226914
corr(e1,e4) | .6803765 .054254 .5593101 .7730249
corr(e1,e6) | .3863277 .0859388 .2064783 .5409252
corr(e4,e6) | .3851844 .0860278 .2051922 .5399742
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(5) = 81.45 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.
. test 1.trt 1.trt#4.time 1.trt#6.time
( 1) [change]1.trt = 0
( 2) [change]1.trt#4.time = 0
( 3) [change]1.trt#6.time = 0
chi2( 3) = 107.79
Prob > chi2 = 0.0000
Analysis of Response Profiles of Adjusted Changes in Response from Baseline
. gen cbaseline=baseline - 26.406
. xtmixed change cbaseline i.trt##i.time || id: , noconst ///
residuals(unstructured, t(time)) reml
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -947.88576
Iteration 1: log restricted-likelihood = -921.6877
Iteration 2: log restricted-likelihood = -912.10282
Iteration 3: log restricted-likelihood = -908.82315
Iteration 4: log restricted-likelihood = -908.78288
Iteration 5: log restricted-likelihood = -908.78281
Computing standard errors:
Mixed-effects REML regression Number of obs = 300
Group variable: id Number of groups = 100
Obs per group: min = 3
avg = 3.0
max = 3
Wald chi2(6) = 138.67
Log restricted-likelihood = -908.78281 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
change | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cbaseline | -.1954811 .0938967 -2.08 0.037 -.3795152 -.0114471
1.trt | -11.35361 1.098486 -10.34 0.000 -13.5066 -9.200618
|
time |
4 | -.5899999 .6427016 -0.92 0.359 -1.849672 .669672
6 | -1.014 .9343096 -1.09 0.278 -2.845213 .8172133
|
trt#time |
1 4 | 2.582 .9089173 2.84 0.005 .8005548 4.363445
1 6 | 8.254 1.321313 6.25 0.000 5.664273 10.84373
|
_cons | -1.638195 .7766451 -2.11 0.035 -3.160391 -.1159981
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: (empty) |
-----------------------------+------------------------------------------------
Residual: Unstructured |
sd(e1) | 5.490989 .393797 4.770952 6.319696
sd(e4) | 5.677179 .4065877 4.933684 6.532717
sd(e6) | 6.283115 .4504089 5.459541 7.230926
corr(e1,e4) | .669291 .0558931 .5448435 .7648909
corr(e1,e6) | .3765418 .0868946 .1950458 .5331034
corr(e4,e6) | .377343 .0868397 .1959302 .5337819
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(5) = 78.21 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.
. test 1.trt 1.trt#4.time 1.trt#6.time
( 1) [change]1.trt = 0
( 2) [change]1.trt#4.time = 0
( 3) [change]1.trt#6.time = 0
chi2( 3) = 111.13
Prob > chi2 = 0.0000