|
|
|
||||
|
|
|||||
Note: The xtmixed procedure is new to Stata 9.
Note on comparing the Stata and SAS results. Stata reports results for fit statistics (e.g. AIC) in "smaller is better" form. Since the printing of the article, SAS has started showing its fit statistics in "smaller is better" form as well.
This first set of examples use the hsb12.dta data file which you can obtain from within Stata like this
use http://www.ats.ucla.edu/stat/paperexamples/singer/hsb12, clear
Example on page 329.
xtmixed mathach || school: , variance
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -23558.397
Iteration 1: log restricted-likelihood = -23558.397
Computing standard errors:
Mixed-effects REML regression Number of obs = 7185
Group variable: school Number of groups = 160
Obs per group: min = 14
avg = 44.9
max = 67
Wald chi2(0) = .
Log restricted-likelihood = -23558.397 Prob > chi2 = .
------------------------------------------------------------------------------
mathach | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_cons | 12.63697 .2443937 51.71 0.000 12.15797 13.11598
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
school: Identity |
var(_cons) | 8.614034 1.078805 6.739129 11.01056
-----------------------------+------------------------------------------------
var(Residual) | 39.14832 .6606446 37.87466 40.46481
------------------------------------------------------------------------------
LR test vs. linear regression: chibar2(01) = 986.12 Prob >= chibar2 = 0.0000
estat ic
------------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+----------------------------------------------------------------
. | 7185 . -23558.4 3 47122.79 47143.43
------------------------------------------------------------------------------
Example on page page 331.
xtmixed mathach meanses || school: , variance
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -23480.642
Iteration 1: log restricted-likelihood = -23480.642
Computing standard errors:
Mixed-effects REML regression Number of obs = 7185
Group variable: school Number of groups = 160
Obs per group: min = 14
avg = 44.9
max = 67
Wald chi2(1) = 263.15
Log restricted-likelihood = -23480.642 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
mathach | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
meanses | 5.863538 .361458 16.22 0.000 5.155094 6.571983
_cons | 12.64944 .1492801 84.74 0.000 12.35685 12.94202
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
school: Identity |
var(_cons) | 2.638707 .4043388 1.954153 3.563067
-----------------------------+------------------------------------------------
var(Residual) | 39.15708 .6608016 37.88312 40.47389
------------------------------------------------------------------------------
LR test vs. linear regression: chibar2(01) = 239.95 Prob >= chibar2 = 0.0000
estat ic
------------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+----------------------------------------------------------------
. | 7185 . -23480.64 4 46969.28 46996.8
------------------------------------------------------------------------------
Example on page 335.
xtmixed mathach cses || school: cses, variance cov(un)
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -23357.18
Iteration 1: log restricted-likelihood = -23357.118
Iteration 2: log restricted-likelihood = -23357.118
Computing standard errors:
Mixed-effects REML regression Number of obs = 7185
Group variable: school Number of groups = 160
Obs per group: min = 14
avg = 44.9
max = 67
Wald chi2(1) = 292.40
Log restricted-likelihood = -23357.118 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
mathach | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
cses | 2.193192 .1282582 17.10 0.000 1.94181 2.444574
_cons | 12.64934 .2445134 51.73 0.000 12.1701 13.12858
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
school: Unstructured |
var(cses) | .6939724 .2807827 .3140105 1.533699
var(_cons) | 8.681651 1.079627 6.803763 11.07785
cov(cses,_cons) | .0507474 .4063922 -.7457667 .8472615
-----------------------------+------------------------------------------------
var(Residual) | 36.7002 .6257441 35.49403 37.94736
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(3) = 1065.70 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference
estat ic
------------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+----------------------------------------------------------------
. | 7185 . -23357.12 6 46726.24 46767.51
------------------------------------------------------------------------------
Example on page 337.
generate msesXcses = meanses*cses
generate secXcses = sector*cses
xtmixed mathach meanses sector cses msesXcses secXcses || school: cses, variance cov(un)
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -23252.888
Iteration 1: log restricted-likelihood = -23251.835
Iteration 2: log restricted-likelihood = -23251.834
Computing standard errors:
Mixed-effects REML regression Number of obs = 7185
Group variable: school Number of groups = 160
Obs per group: min = 14
avg = 44.9
max = 67
Wald chi2(5) = 746.22
Log restricted-likelihood = -23251.834 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
mathach | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
meanses | 5.339122 .3693012 14.46 0.000 4.615305 6.062939
sector | 1.216671 .3063874 3.97 0.000 .6161622 1.817179
cses | 2.938756 .1551034 18.95 0.000 2.634759 3.242753
msesXcses | 1.038844 .2989198 3.48 0.001 .4529717 1.624716
secXcses | -1.642572 .2398074 -6.85 0.000 -2.112586 -1.172558
_cons | 12.11359 .1988085 60.93 0.000 11.72393 12.50324
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
school: Unstructured |
var(cses) | .1016223 .2134717 .0016555 6.238148
var(_cons) | 2.381904 .3717541 1.754178 3.234261
cov(cses,_cons) | .1924953 .204535 -.2083859 .5933765
-----------------------------+------------------------------------------------
var(Residual) | 36.72101 .6261091 35.51414 37.9689
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(3) = 220.57 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference
estimates store M1
estat ic
------------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+----------------------------------------------------------------
M1 | 7185 . -23251.83 10 46523.67 46592.47
------------------------------------------------------------------------------
Example on page 339.
xtmixed mathach meanses sector cses meanses*cses sector*cses || school: , variance
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -23252.397
Iteration 1: log restricted-likelihood = -23252.397
Computing standard errors:
Mixed-effects REML regression Number of obs = 7185
Group variable: school Number of groups = 160
Obs per group: min = 14
avg = 44.9
max = 67
Wald chi2(5) = 765.44
Log restricted-likelihood = -23252.397 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
mathach | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
meanses | 5.342945 .3689877 14.48 0.000 4.619742 6.066148
sector | 1.214627 .3061252 3.97 0.000 .6146327 1.814621
cses | 2.935841 .1507053 19.48 0.000 2.640464 3.231218
meansesBYc~s | 1.044086 .2910422 3.59 0.000 .4736542 1.614519
sectorBYcses | -1.64207 .2330966 -7.04 0.000 -2.09893 -1.185209
_cons | 12.11382 .1986485 60.98 0.000 11.72448 12.50317
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
school: Identity |
var(_cons) | 2.375333 .3709728 1.748986 3.225988
-----------------------------+------------------------------------------------
var(Residual) | 36.76611 .6206516 35.56956 38.00291
------------------------------------------------------------------------------
LR test vs. linear regression: chibar2(01) = 219.44 Prob >= chibar2 = 0.0000
estimates store M2
estat ic
------------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+----------------------------------------------------------------
M2 | 7185 . -23252.4 8 46520.79 46575.83
------------------------------------------------------------------------------
estimates stats M1 M2
------------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+----------------------------------------------------------------
M1 | 7185 . -23251.83 10 46523.67 46592.47
M2 | 7185 . -23252.4 8 46520.79 46575.83
------------------------------------------------------------------------------
The next set of examples use the willett.dta data which you can obtain from within Stata like this.
use http://www.ats.ucla.edu/stat/paperexamples/singer/willett, clear
Example on pages 341/342.
xtmixed y time || id: time, variance cov(un)
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -633.41137
Iteration 1: log restricted-likelihood = -633.41137
Computing standard errors:
Mixed-effects REML regression Number of obs = 140
Group variable: id Number of groups = 35
Obs per group: min = 4
avg = 4.0
max = 4
Wald chi2(1) = 154.84
Log restricted-likelihood = -633.41137 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
time | 26.96 2.166604 12.44 0.000 22.71353 31.20647
_cons | 164.3743 6.118849 26.86 0.000 152.3816 176.367
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured |
var(time) | 132.4006 40.2107 73.0089 240.1065
var(_cons) | 1198.777 318.3812 712.3102 2017.472
cov(time,_cons) | -179.2556 88.96347 -353.6208 -4.890378
-----------------------------+------------------------------------------------
var(Residual) | 159.4771 26.95655 114.5036 222.1149
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(3) = 120.90 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference
estat ic
------------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+----------------------------------------------------------------
. | 140 . -633.4114 6 1278.823 1296.473
------------------------------------------------------------------------------
Example on page 344.
xtmixed y time ccovar timeBYccovar || id: time, variance cov(un)
Performing EM optimization:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -630.14238
Iteration 1: log restricted-likelihood = -630.14238
Computing standard errors:
Mixed-effects REML regression Number of obs = 140
Group variable: id Number of groups = 35
Obs per group: min = 4
avg = 4.0
max = 4
Wald chi2(3) = 191.86
Log restricted-likelihood = -630.14238 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
y | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
time | 26.96 1.993881 13.52 0.000 23.05207 30.86794
ccovar | -.1135527 .5040119 -0.23 0.822 -1.101398 .8742925
timeBYccovar | .4328577 .1619278 2.67 0.008 .115485 .7502305
_cons | 164.3743 6.206096 26.49 0.000 152.2106 176.538
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
id: Unstructured |
var(time) | 107.2492 34.6767 56.90841 202.1211
var(_cons) | 1236.413 332.4024 730.0001 2094.132
cov(time,_cons) | -178.2333 85.42982 -345.6726 -10.79389
-----------------------------+------------------------------------------------
var(Residual) | 159.4771 26.95656 114.5036 222.1149
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(3) = 120.72 Prob > chi2 = 0.0000
Note: LR test is conservative and provided only for reference
estat ic
------------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+----------------------------------------------------------------
. | 140 . -630.1424 8 1276.285 1299.818
------------------------------------------------------------------------------
Examples on pages 346 & 348, cannot be done in Stata at this time. Stata does not have a repeated option for the fixed effects.
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services