UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

Stata Textbook Examples
Design and Analysis by Geoffrey Keppel
Chapter 11: Detailed Analysis of Main Effects and Simple Effects

In chapter 11 Keppel shows how to perform comparisons of main effects and simple effects in a two way factorial anova based on the example from chapter 10. Let's start by running the basic anova from chapter 10.
use http://www.ats.ucla.edu/stat/stata/examples/da/chap10, clear

anova errors a b a*b


                           Number of obs =      24     R-squared     =  0.4590
                           Root MSE      = 4.28174     Adj R-squared =  0.3087

                  Source |  Partial SS    df       MS           F     Prob > F
              -----------+----------------------------------------------------
                   Model |      280.00     5       56.00       3.05     0.0361
                         |
                       a |      112.00     2       56.00       3.05     0.0721
                       b |       24.00     1       24.00       1.31     0.2675
                     a*b |      144.00     2       72.00       3.93     0.0384
                         |
                Residual |      330.00    18  18.3333333   
              -----------+----------------------------------------------------
                   Total |      610.00    23  26.5217391
On page 234 Keppel shows a comparison comparing group a1 with group a3 We create a variable acomp1 that compares group a1 with group a3.
gen acomp1=a
recode acomp1 1=1 2=0 3=-1
We also create a variable acomp2 that is orthogonal to acomp1.
gen acomp2=a
recode acomp2 1=1 2=-2 3=1
We now run the anova, replacing a with acomp1 acomp2, and adding contin(acomp1 acomp2). We see the effect acomp1 is the same as shown on page 234.
anova errors acomp1 acomp2 b acomp1*b acomp2*b , contin(acomp1 acomp2)

                           Number of obs =      24     R-squared     =  0.4590
                           Root MSE      = 4.28174     Adj R-squared =  0.3087

                  Source |  Partial SS    df       MS           F     Prob > F
              -----------+----------------------------------------------------
                   Model |      280.00     5       56.00       3.05     0.0361
                         |
                  acomp1 |      100.00     1      100.00       5.45     0.0313
                  acomp2 |       12.00     1       12.00       0.65     0.4291
                       b |       24.00     1       24.00       1.31     0.2675
                acomp1*b |      144.00     1      144.00       7.85     0.0118
                acomp2*b |        0.00     1        0.00       0.00     1.0000
                         |
                Residual |      330.00    18  18.3333333   
              -----------+----------------------------------------------------
                   Total |      610.00    23  26.5217391
On page 241, Keppel shows how to perform tests of simple main effects testing the effect of A at b1 and b2. Stata does not have a built in command for computing simple main effects, however UCLA Academic Technology Services has created a command sme which will compute this for you and can be downloaded by typing findit sme in the command line and proceed with the installation  (see How can I use the findit command to search for programs and get additional help? for more information about using findit).

Now, we rerun the original anova as shown below.

anova errors a b a*b

                           Number of obs =      24     R-squared     =  0.4590
                           Root MSE      = 4.28174     Adj R-squared =  0.3087

                  Source |  Partial SS    df       MS           F     Prob > F
              -----------+----------------------------------------------------
                   Model |      280.00     5       56.00       3.05     0.0361
                         |
                       a |      112.00     2       56.00       3.05     0.0721
                       b |       24.00     1       24.00       1.31     0.2675
                     a*b |      144.00     2       72.00       3.93     0.0384
                         |
                Residual |      330.00    18  18.3333333   
              -----------+----------------------------------------------------
                   Total |      610.00    23  26.5217391
Now we get the simple effects of A at b1 and b2.
sme a b

Test of a at b(1): F(2/18)  = 6.7636364
Test of a at b(2): F(2/18)  = .21818182


Critical value of F for alpha = .05 using ...
--------------------------------------------------
Dunn's procedure              = 4.2877197
Marascuilo & Levin            = 4.9000978
per family error rate         = 4.5596361
simultaneous test procedure   = 4.6736374
Page 246 shows how to do a simple comparison. We have skipped this for now, as we are not sure how to do this in Stata.

How to cite this page

Report an error on this page

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.