UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

Stata FAQ
How can I check for homogeneity of variance in a factorial anova design?

To analyze a factorial anova you would use the anova command. The anova command does not have a check for homogeneity of variance. However, the oneway command automatically performs a Bartlett's test for homogeneity of variance along with a one-way anova. The trick is to convert your factorial design into a one-way design.

Let's say that you want to run a 2x4 factorial using the file crf24.dta. The following commands will illustrate the process:

use http://www.ats.ucla.edu/stat/stata/faq/crf24
anova y a b a*b

   Number of obs =      32     R-squared     =  0.9214
   Root MSE      = .877971     Adj R-squared =  0.8985

  Source |  Partial SS    df       MS           F     Prob > F
---------+----------------------------------------------------
   Model |      217.00     7       31.00      40.22     0.0000
         |
       a |       3.125     1       3.125       4.05     0.0554
       b |      194.50     3  64.8333333      84.11     0.0000
     a*b |      19.375     3  6.45833333       8.38     0.0006
         |
Residual |       18.50    24  .770833333   
---------+----------------------------------------------------
   Total |      235.50    31  7.59677419  

Now enter these commands:

egen cell = group(a b)
robvar y, by(cell)

            |            Summary of y
 group(a b) |        Mean   Std. Dev.       Freq.
------------+------------------------------------
          1 |        3.75         1.5           4
          2 |           4   .81649658           4
          3 |           7   .81649658           4
          4 |           8   .81649658           4
          5 |        1.75          .5           4
          6 |           3   .81649658           4
          7 |         5.5   .57735027           4
          8 |          10   .81649658           4
------------+------------------------------------
      Total |       5.375   2.7562246          32

W0  = .74805195   df(7, 24)     Pr > F = .63460714

W50 = .13714286   df(7, 24)     Pr > F = .99422247

W10 = .74805195   df(7, 24)     Pr > F = .63460714

The variable cell created using the egen command takes on the values 1 through 8.  The robvar command gives you Levene's test of homogeneity (labeled W0).

Note:  Levene's test is reletively more robust to nonnormality than other tests of homogeneity but can still be influenced by nonnormality and should be used with caution. 


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