UCLA Academic Technology Services HomeServicesClassesContactJobs
Help the Stat Consulting Group by giving a gift             
Loading

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

Page 120 shows how to compare treatment means following a one way anova. This analysis shows a comparison of group 1 versus 2 and 3, and a second comparison of group 2 versus 3. We can use the user-defined coding option with xi3 to create these comparisons. You can download the xi3 command by typing findit xi3 (see How can I use the findit command to search for programs and get additional help? for more information about using findit). We will first use the char command to set the characteristic of variable a to be the contrasts that we want.
clear
input scores a
16 1
18 1
10 1
12 1
19 1
 4 2
 6 2
 8 2
10 2
 2 2
 2 3
10 3
 9 3
13 3
11 3
end

char a[user] (1 -.5 -.5\0 1 -1)
xi3:  regress score u.a

u.a               _Ia_1-3             (naturally coded; _Ia_3 omitted)

      Source |       SS       df       MS              Number of obs =      15
-------------+------------------------------           F(  2,    12) =    7.41
       Model |      210.00     2      105.00           Prob > F      =  0.0080
    Residual |      170.00    12  14.1666667           R-squared     =  0.5526
-------------+------------------------------           Adj R-squared =  0.4781
       Total |      380.00    14  27.1428571           Root MSE      =  3.7639

------------------------------------------------------------------------------
       score |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _Ia_1 |        7.5   2.061553     3.64   0.003     3.008262    11.99174
       _Ia_2 |         -3   2.380476    -1.26   0.232    -8.186612    2.186612
       _cons |         10   .9718253    10.29   0.000     7.882575    12.11743
------------------------------------------------------------------------------
The tests above are shown in terms of t-tests, but we can use the test command to obtain the F values shown in the text.
test  _Ia_1

 ( 1)  _Ia_1 = 0.0

       F(  1,    12) =   13.24
            Prob > F =    0.0034


test    _Ia_2

 ( 1)  _Ia_2 = 0.0

       F(  1,    12) =    1.59
            Prob > F =    0.2315

How to cite this page

Report an error on this page or leave a comment

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


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.