### Stata Textbook Examples Design and Analysis by Geoffrey Keppel Chapter 6: Analytical Comparisons Among Treatment Means

Version info: Code for this page has been updated to Stata 12.

Page 120 shows how to compare treatment means following a one way anova. First, let's run the basic anova.
use http://www.ats.ucla.edu/stat/stata/examples/da/chap2, clear

anova score a

Number of obs =      15     R-squared     =  0.5526
Root MSE      = 3.76386     Adj R-squared =  0.4781

Source |  Partial SS    df       MS           F     Prob > F
-----------+----------------------------------------------------
Model |      210.00     2      105.00       7.41     0.0080
|
a |      210.00     2      105.00       7.41     0.0080
|
Residual |      170.00    12  14.1666667
-----------+----------------------------------------------------
Total |      380.00    14  27.1428571   
Page 120 shows a comparison of group 1 versus 2 and 3, and a second comparison of group 2 versus 3. We will use the contrast command with user defined weights.
contrast {a 1 -.5 -.5}{a 0 1 -1}, effects
Contrasts of marginal linear predictions

Margins      : asbalanced

------------------------------------------------
|         df           F        P>F
-------------+----------------------------------
a |
(1)  |          1       13.24     0.0034
(2)  |          1        1.59     0.2315
Joint  |          2        7.41     0.0080
|
Residual |         12
------------------------------------------------

------------------------------------------------------------------------------
|   Contrast   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
a |
(1)  |        7.5   2.061553     3.64   0.003     3.008262    11.99174
(2)  |         -3   2.380476    -1.26   0.232    -8.186612    2.186612
------------------------------------------------------------------------------

The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.