Professional Documents
Culture Documents
A and Azen (1979) tted a model of the change in systolic blood pressure for 58 patients, each suffering from one of three diseases, who were
randomly assigned one of four different drug treatments:
https://www.stata.com/features/overview/anova-ancova/ 1/8
4/11/2018 ANOVA / ANCOVA | Stata
. webuse systolic
(Systolic Blood Pressure Data)
An important feature of Stata is that it does not have modes or modules. You do not enter the ANOVA module to t an ANOVA model. The
advantage in this is that all Stata’s features can be interspersed to help you better understand these data. For instance, the data here are almost
balanced, as revealed by Stata's table:
1 6 4 5 15
2 5 4 6 15
3 3 5 4 12
4 5 6 5 16
Total 19 19 20 58
table can also be used to help you better understand the relationship of the increase in blood pressure by drug and disease:
https://www.stata.com/features/overview/anova-ancova/ 2/8
4/11/2018 ANOVA / ANCOVA | Stata
Stata's test allows you to perform tests directly on the coe cients of the underlying regression model. For instance, we can test if the coe cient on
the third drug is equal to the coe cient on the fourth.
F( 1, 46) = 0.13
Prob > F = 0.7234
We nd that the two coe cients are not signi cantly different, at least at any signi cance level smaller than 73%.
For more complex tests, contrast often provides a more concise way to specify the test we are interested in and prevents us from having to write
tests in terms of the regression coe cients. With contrast, we instead specify our tests in terms of differences in the marginal means for the levels
of a particular factor. For example, if we want to compare the third and fourth drugs, we can test the difference in the mean impact on systolic
blood pressure separately for each disease using the @ operator. We also use the reverse adjacent operator, ar., to compare the fourth level of the
drug with the previous level.
https://www.stata.com/features/overview/anova-ancova/ 3/8
4/11/2018 ANOVA / ANCOVA | Stata
. contrast ar4.drug@disease
Contrasts of marginal linear predictions
Margins : asbalanced
df F P>F
drug@disease
(4 vs 3) 1 1 0.13 0.7234
(4 vs 3) 2 1 1.76 0.1917
(4 vs 3) 3 1 0.65 0.4230
Joint 3 0.85 0.4761
Denominator 46
drug@disease
(4 vs 3) 1 -2.733333 7.675156 -18.18262 12.71595
(4 vs 3) 2 8.433333 6.363903 -4.376539 21.24321
(4 vs 3) 3 5.7 7.050081 -8.491077 19.89108
test and contrast can still access the estimates, even though two tabulations have intervened. Similarly, anova is integrated with Stata’s regress for
estimating linear regressions. We can review the underlying regression estimates by typing regress without arguments:
https://www.stata.com/features/overview/anova-ancova/ 4/8
4/11/2018 ANOVA / ANCOVA | Stata
. regress
Source SS df MS Number of obs = 58
F( 11, 46) = 3.51
Model 4259.33851 11 387.212591 Prob > F = 0.0013
Residual 5080.81667 46 110.452536 R-squared = 0.4560
Adj R-squared = 0.3259
Total 9340.15517 57 163.862371 Root MSE = 10.51
drug
2 -1.333333 6.363903 -0.21 0.835 -14.14321 11.47654
3 -13 7.431438 -1.75 0.087 -27.95871 1.958708
4 -15.73333 6.363903 -2.47 0.017 -28.54321 -2.923461
disease
2 -1.083333 6.783944 -0.16 0.874 -14.7387 12.57204
3 -8.933333 6.363903 -1.40 0.167 -21.74321 3.876539
drug#disease
2 2 6.583333 9.783943 0.67 0.504 -13.11072 26.27739
2 3 -.9 8.999918 -0.10 0.921 -19.0159 17.2159
3 2 -10.85 10.24353 -1.06 0.295 -31.46916 9.769157
3 3 1.1 10.24353 0.11 0.915 -19.51916 21.71916
4 2 .3166667 9.301675 0.03 0.973 -18.40663 19.03997
4 3 9.533333 9.202189 1.04 0.306 -8.989712 28.05638
In our original estimation, the direct effect of disease was found to be insigni cant, as was the drug#disease interaction. We might now compare
our two-way factorial model with a simpler, one-way layout:
https://www.stata.com/features/overview/anova-ancova/ 5/8
4/11/2018 ANOVA / ANCOVA | Stata
With the test example above, we found that a one-way model ts these data well. We could use either Stata's anova or Stata’s oneway to t a one-
way model.
2 -.533333
1.000
3 -17.3167 -16.7833
0.001 0.001
Table 7.7 of Winer, Brown, and Michels (1991) provides a repeated-measures ANOVA example involving both nested and crossed terms. There are
four dial shapes and two methods for calibrating dials. Subjects are nested within the calibration method, and an accuracy score is obtained.
https://www.stata.com/features/overview/anova-ancova/ 6/8
4/11/2018 ANOVA / ANCOVA | Stata
. webuse t77
(T7.7 -- Winer, Brown, Michels)
References
https://www.stata.com/features/overview/anova-ancova/ 7/8
4/11/2018 ANOVA / ANCOVA | Stata
Stata Shop
Support Company
Training Contact us
Video tutorials Customer service
FAQs Announcements
Statalist: The Stata Forum Search
Resources
Technical support
Customer service
© Copyright 1996–2018 StataCorp LLC • Terms of use • Privacy • Contact us
https://www.stata.com/features/overview/anova-ancova/ 8/8