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 2×4 factorial using the file **crf24.dta**. The
following commands will illustrate the process:

use https://stats.idre.ucla.edu/stat/stata/faq/crf24 anova y a b a#bNumber 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 relatively more robust to nonnormality than other
tests of homogeneity but can still be influenced by nonnormality and should be used with caution.