------------------------------------------------------------------------------------------------------------------------------------------------------
name: STATA_Chapter3b
log: C:\Dropbox\PilesOfVariance\Chapter3b\STATA\STATA_Chapter3b_Output.smcl
log type: smcl
opened on: 12 Jan 2015, 10:32:54
.
. display as result "Chapter 3b Example: Means by session for RT outcome"
Chapter 3b Example: Means by session for RT outcome
. tabulate session, summarize(rt)
session: | Summary of rt: Response Time in
Occasion | Milliseconds
(1-6) | Mean Std. Dev. Freq.
------------+------------------------------------
1 | 1961.8934 549.53193 101
2 | 1815.1724 509.06784 101
3 | 1750.0346 483.08178 101
4 | 1717.7965 466.41575 101
5 | 1707.1757 460.54053 101
6 | 1672.136 443.54613 101
------------+------------------------------------
Total | 1770.7014 494.08763 606
.
. display as result "Eq 3b.10: Between-Person Independent ANOVA"
Eq 3b.10: Between-Person Independent ANOVA
. mixed rt i.session, ///
> || personid: , noconstant variance reml covariance(unstructured) ///
> residuals(independent,t(session)),
Note: t() not required for this residual structure; ignored
Note: all random-effects equations are empty; model is linear regression
Mixed-effects REML regression Number of obs = 606
Wald chi2(5) = 23.67
Log restricted-likelihood = -4577.7163 Prob > chi2 = 0.0003
------------------------------------------------------------------------------
rt | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
session |
2 | -146.721 68.47894 -2.14 0.032 -280.9372 -12.50472
3 | -211.8587 68.47894 -3.09 0.002 -346.075 -77.64246
4 | -244.0969 68.47894 -3.56 0.000 -378.3132 -109.8806
5 | -254.7176 68.47894 -3.72 0.000 -388.9339 -120.5014
6 | -289.7574 68.47894 -4.23 0.000 -423.9736 -155.5411
|
_cons | 1961.893 48.42193 40.52 0.000 1866.988 2056.799
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
var(Residual) | 236813 13604.55 211594.9 265036.5
------------------------------------------------------------------------------
. estat ic, n(101),
Akaike's information criterion and Bayesian information criterion
-----------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+---------------------------------------------------------------
. | 101 . -4577.716 7 9169.433 9187.738
-----------------------------------------------------------------------------
Note: N=101 used in calculating BIC
. estat wcorrelation, covariance,
model is linear regression; all observations are independent with standard deviation 486.63433
. estat wcorrelation,
model is linear regression; all observations are independent with standard deviation 486.63433
. contrast i.session,
Contrasts of marginal linear predictions
Margins : asbalanced
------------------------------------------------
| df chi2 P>chi2
-------------+----------------------------------
rt |
session | 5 23.67 0.0003
------------------------------------------------
. margins i.session,
Adjusted predictions Number of obs = 606
Expression : Linear prediction, fixed portion, predict()
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
session |
1 | 1961.893 48.42193 40.52 0.000 1866.988 2056.799
2 | 1815.172 48.42193 37.49 0.000 1720.267 1910.078
3 | 1750.035 48.42193 36.14 0.000 1655.129 1844.94
4 | 1717.796 48.42193 35.48 0.000 1622.891 1812.702
5 | 1707.176 48.42193 35.26 0.000 1612.271 1802.081
6 | 1672.136 48.42193 34.53 0.000 1577.231 1767.041
------------------------------------------------------------------------------
. margins i.session, pwcompare(pveffects)
Pairwise comparisons of adjusted predictions
Expression : Linear prediction, fixed portion, predict()
-----------------------------------------------------
| Delta-method Unadjusted
| Contrast Std. Err. z P>|z|
-------------+---------------------------------------
session |
2 vs 1 | -146.721 68.47894 -2.14 0.032
3 vs 1 | -211.8587 68.47894 -3.09 0.002
4 vs 1 | -244.0969 68.47894 -3.56 0.000
5 vs 1 | -254.7176 68.47894 -3.72 0.000
6 vs 1 | -289.7574 68.47894 -4.23 0.000
3 vs 2 | -65.13774 68.47894 -0.95 0.341
4 vs 2 | -97.37592 68.47894 -1.42 0.155
5 vs 2 | -107.9967 68.47894 -1.58 0.115
6 vs 2 | -143.0364 68.47894 -2.09 0.037
4 vs 3 | -32.23819 68.47894 -0.47 0.638
5 vs 3 | -42.85892 68.47894 -0.63 0.531
6 vs 3 | -77.89864 68.47894 -1.14 0.255
5 vs 4 | -10.62073 68.47894 -0.16 0.877
6 vs 4 | -45.66045 68.47894 -0.67 0.505
6 vs 5 | -35.03972 68.47894 -0.51 0.609
-----------------------------------------------------
. estimates store FitBPANOVA,
.
. display as result "Eq 3b.10: Univariate Repeated Measures ANOVA"
Eq 3b.10: Univariate Repeated Measures ANOVA
. mixed rt i.session, ///
> || personid: , noconstant variance reml covariance(unstructured) ///
> residuals(exchangeable,t(session)),
Note: t() not required for this residual structure; ignored
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -4577.7163
Iteration 1: log restricted-likelihood = -4185.4324
Iteration 2: log restricted-likelihood = -4176.7438
Iteration 3: log restricted-likelihood = -4176.6776
Iteration 4: log restricted-likelihood = -4176.6776
Computing standard errors:
Mixed-effects REML regression Number of obs = 606
Group variable: personid Number of groups = 101
Obs per group: min = 6
avg = 6.0
max = 6
Wald chi2(5) = 164.24
Log restricted-likelihood = -4176.6776 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
rt | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
session |
2 | -146.721 25.99932 -5.64 0.000 -197.6787 -95.76326
3 | -211.8587 25.99932 -8.15 0.000 -262.8164 -160.901
4 | -244.0969 25.99932 -9.39 0.000 -295.0546 -193.1392
5 | -254.7176 25.99932 -9.80 0.000 -305.6754 -203.7599
6 | -289.7574 25.99932 -11.14 0.000 -340.7151 -238.7996
|
_cons | 1961.893 48.42193 40.52 0.000 1866.988 2056.799
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
personid: (empty) |
-----------------------------+------------------------------------------------
Residual: Exchangeable |
var(e) | 236813 29522.31 185477.2 302357.5
cov(e) | 202676.8 29469.63 144917.4 260436.3
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(1) = 802.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.
. estat ic, n(101),
Akaike's information criterion and Bayesian information criterion
-----------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+---------------------------------------------------------------
. | 101 . -4176.678 8 8369.355 8390.276
-----------------------------------------------------------------------------
Note: N=101 used in calculating BIC
. estat wcorrelation, covariance,
Covariances for personid = 101:
obs | 1 2 3 4 5 6
-------------+------------------------------------------------
1 | 2.4e+05
2 | 2.0e+05 2.4e+05
3 | 2.0e+05 2.0e+05 2.4e+05
4 | 2.0e+05 2.0e+05 2.0e+05 2.4e+05
5 | 2.0e+05 2.0e+05 2.0e+05 2.0e+05 2.4e+05
6 | 2.0e+05 2.0e+05 2.0e+05 2.0e+05 2.0e+05 2.4e+05
. estat wcorrelation,
Standard deviations and correlations for personid = 101:
Standard deviations:
obs | 1 2 3 4 5 6
-------------+------------------------------------------------
sd | 486.634 486.634 486.634 486.634 486.634 486.634
Correlations:
obs | 1 2 3 4 5 6
-------------+------------------------------------------------
1 | 1.000
2 | 0.856 1.000
3 | 0.856 0.856 1.000
4 | 0.856 0.856 0.856 1.000
5 | 0.856 0.856 0.856 0.856 1.000
6 | 0.856 0.856 0.856 0.856 0.856 1.000
. contrast i.session,
Contrasts of marginal linear predictions
Margins : asbalanced
------------------------------------------------
| df chi2 P>chi2
-------------+----------------------------------
rt |
session | 5 164.24 0.0000
------------------------------------------------
. margins i.session,
Adjusted predictions Number of obs = 606
Expression : Linear prediction, fixed portion, predict()
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
session |
1 | 1961.893 48.42193 40.52 0.000 1866.988 2056.799
2 | 1815.172 48.42193 37.49 0.000 1720.267 1910.078
3 | 1750.035 48.42193 36.14 0.000 1655.129 1844.94
4 | 1717.796 48.42193 35.48 0.000 1622.891 1812.702
5 | 1707.176 48.42193 35.26 0.000 1612.27 1802.081
6 | 1672.136 48.42193 34.53 0.000 1577.231 1767.041
------------------------------------------------------------------------------
. margins i.session, pwcompare(pveffects)
Pairwise comparisons of adjusted predictions
Expression : Linear prediction, fixed portion, predict()
-----------------------------------------------------
| Delta-method Unadjusted
| Contrast Std. Err. z P>|z|
-------------+---------------------------------------
session |
2 vs 1 | -146.721 25.99932 -5.64 0.000
3 vs 1 | -211.8587 25.99932 -8.15 0.000
4 vs 1 | -244.0969 25.99932 -9.39 0.000
5 vs 1 | -254.7176 25.99932 -9.80 0.000
6 vs 1 | -289.7574 25.99932 -11.14 0.000
3 vs 2 | -65.13774 25.99932 -2.51 0.012
4 vs 2 | -97.37592 25.99932 -3.75 0.000
5 vs 2 | -107.9967 25.99932 -4.15 0.000
6 vs 2 | -143.0364 25.99932 -5.50 0.000
4 vs 3 | -32.23819 25.99932 -1.24 0.215
5 vs 3 | -42.85892 25.99932 -1.65 0.099
6 vs 3 | -77.89864 25.99932 -3.00 0.003
5 vs 4 | -10.62073 25.99932 -0.41 0.683
6 vs 4 | -45.66045 25.99932 -1.76 0.079
6 vs 5 | -35.03972 25.99932 -1.35 0.178
-----------------------------------------------------
. estimates store FitUnivANOVA,
. lrtest FitUnivANOVA FitBPANOVA,
Likelihood-ratio test LR chi2(1) = 802.08
(Assumption: FitBPANOVA nested in FitUnivANOVA) Prob > chi2 = 0.0000
Note: LR tests based on REML are valid only when the fixed-effects specification is identical for both models.
.
. display as result "Eq 3b.10: Multivariate Repeated Measures ANOVA"
Eq 3b.10: Multivariate Repeated Measures ANOVA
. mixed rt i.session, ///
> || personid: , noconstant variance reml covariance(unstructured) ///
> residuals(unstructured,t(session)),
Obtaining starting values by EM:
Performing gradient-based optimization:
Iteration 0: log restricted-likelihood = -4577.7163 (not concave)
Iteration 1: log restricted-likelihood = -4203.3431
Iteration 2: log restricted-likelihood = -4161.6274 (not concave)
Iteration 3: log restricted-likelihood = -4127.1235
Iteration 4: log restricted-likelihood = -4118.1617
Iteration 5: log restricted-likelihood = -4114.9737
Iteration 6: log restricted-likelihood = -4114.8943
Iteration 7: log restricted-likelihood = -4114.8942
Computing standard errors:
Mixed-effects REML regression Number of obs = 606
Group variable: personid Number of groups = 101
Obs per group: min = 6
avg = 6.0
max = 6
Wald chi2(5) = 83.60
Log restricted-likelihood = -4114.8942 Prob > chi2 = 0.0000
------------------------------------------------------------------------------
rt | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
session |
2 | -146.721 29.82087 -4.92 0.000 -205.1688 -88.27315
3 | -211.8587 31.3658 -6.75 0.000 -273.3346 -150.3829
4 | -244.0969 33.64274 -7.26 0.000 -310.0355 -178.1583
5 | -254.7176 35.84557 -7.11 0.000 -324.9737 -184.4616
6 | -289.7574 32.69999 -8.86 0.000 -353.8482 -225.6666
|
_cons | 1961.893 54.68037 35.88 0.000 1854.722 2069.065
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
personid: (empty) |
-----------------------------+------------------------------------------------
Residual: Unstructured |
var(e1) | 301984.3 42695.54 228896.2 398409.8
var(e2) | 259149.5 36634.32 196436.2 341884.5
var(e3) | 233367.6 32989.07 176894.3 307869.9
var(e4) | 217543.3 30752.36 164899 286994.3
var(e5) | 212097.3 29983.2 160769.9 279811.5
var(e6) | 196732.8 27810.84 149124.2 259540.8
cov(e1,e2) | 235658.1 36562.36 163997.1 307319
cov(e1,e3) | 217993.4 34334.82 150698.3 285288.4
cov(e1,e4) | 202606.2 32656.16 138601.3 266611.1
cov(e1,e5) | 192153.1 31760.42 129903.8 254402.4
cov(e1,e6) | 195359.4 31222.49 134164.5 256554.4
cov(e2,e3) | 230216.3 33671.07 164222.2 296210.4
cov(e2,e4) | 213231.3 31897.72 150712.9 275749.6
cov(e2,e5) | 202091.6 30936.96 141456.3 262726.9
cov(e2,e6) | 193267.8 29705.99 135045.2 251490.5
cov(e3,e4) | 205208.6 30461.36 145505.4 264911.8
cov(e3,e5) | 196918.3 29696.25 138714.7 255121.9
cov(e3,e6) | 188604 28530.72 132684.9 244523.2
cov(e4,e5) | 193675.3 28908.89 137014.9 250335.7
cov(e4,e6) | 185320.6 27760.99 130910 239731.1
cov(e5,e6) | 187840 27738.3 133474 242206.1
------------------------------------------------------------------------------
LR test vs. linear regression: chi2(20) = 925.64 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.
. estat ic, n(101),
Akaike's information criterion and Bayesian information criterion
-----------------------------------------------------------------------------
Model | Obs ll(null) ll(model) df AIC BIC
-------------+---------------------------------------------------------------
. | 101 . -4114.894 27 8283.788 8354.397
-----------------------------------------------------------------------------
Note: N=101 used in calculating BIC
. estat wcorrelation, covariance,
Covariances for personid = 101:
session | 1 2 3 4 5 6
-------------+------------------------------------------------
1 | 3.0e+05
2 | 2.4e+05 2.6e+05
3 | 2.2e+05 2.3e+05 2.3e+05
4 | 2.0e+05 2.1e+05 2.1e+05 2.2e+05
5 | 1.9e+05 2.0e+05 2.0e+05 1.9e+05 2.1e+05
6 | 2.0e+05 1.9e+05 1.9e+05 1.9e+05 1.9e+05 2.0e+05
. estat wcorrelation,
Standard deviations and correlations for personid = 101:
Standard deviations:
session | 1 2 3 4 5 6
-------------+------------------------------------------------
sd | 549.531 509.067 483.081 466.415 460.540 443.546
Correlations:
session | 1 2 3 4 5 6
-------------+------------------------------------------------
1 | 1.000
2 | 0.842 1.000
3 | 0.821 0.936 1.000
4 | 0.790 0.898 0.911 1.000
5 | 0.759 0.862 0.885 0.902 1.000
6 | 0.802 0.856 0.880 0.896 0.920 1.000
. contrast i.session,
Contrasts of marginal linear predictions
Margins : asbalanced
------------------------------------------------
| df chi2 P>chi2
-------------+----------------------------------
rt |
session | 5 83.60 0.0000
------------------------------------------------
. margins i.session,
Adjusted predictions Number of obs = 606
Expression : Linear prediction, fixed portion, predict()
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
session |
1 | 1961.893 54.68037 35.88 0.000 1854.722 2069.065
2 | 1815.172 50.65409 35.83 0.000 1715.892 1914.453
3 | 1750.035 48.06839 36.41 0.000 1655.822 1844.247
4 | 1717.796 46.41007 37.01 0.000 1626.834 1808.759
5 | 1707.176 45.82547 37.25 0.000 1617.359 1796.992
6 | 1672.136 44.13445 37.89 0.000 1585.634 1758.638
------------------------------------------------------------------------------
. margins i.session, pwcompare(pveffects)
Pairwise comparisons of adjusted predictions
Expression : Linear prediction, fixed portion, predict()
-----------------------------------------------------
| Delta-method Unadjusted
| Contrast Std. Err. z P>|z|
-------------+---------------------------------------
session |
2 vs 1 | -146.721 29.82087 -4.92 0.000
3 vs 1 | -211.8587 31.3658 -6.75 0.000
4 vs 1 | -244.0969 33.64274 -7.26 0.000
5 vs 1 | -254.7176 35.84557 -7.11 0.000
6 vs 1 | -289.7574 32.69999 -8.86 0.000
3 vs 2 | -65.13774 17.82326 -3.65 0.000
4 vs 2 | -97.37592 22.3009 -4.37 0.000
5 vs 2 | -107.9967 25.76813 -4.19 0.000
6 vs 2 | -143.0364 26.20307 -5.46 0.000
4 vs 3 | -32.23819 20.02319 -1.61 0.107
5 vs 3 | -42.85892 22.60911 -1.90 0.058
6 vs 3 | -77.89864 22.8842 -3.40 0.001
5 vs 4 | -10.62073 20.4625 -0.52 0.604
6 vs 4 | -45.66045 20.78531 -2.20 0.028
6 vs 5 | -35.03972 18.11681 -1.93 0.053
-----------------------------------------------------
. estimates store FitMultivANOVA,
. lrtest FitMultivANOVA FitUnivANOVA,
Likelihood-ratio test LR chi2(19) = 123.57
(Assumption: FitUnivANOVA nested in FitMultivANOVA) 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.
Note: LR tests based on REML are valid only when the fixed-effects specification is identical for both models.
.
. ****** END CHAPTER 3b MODELS ******
.
. * Close log
. log close STATA_Chapter3b
name: STATA_Chapter3b
log: C:\Dropbox\PilesOfVariance\Chapter3b\STATA\STATA_Chapter3b_Output.smcl
log type: smcl
closed on: 12 Jan 2015, 10:33:33
------------------------------------------------------------------------------------------------------------------------------------------------------