# Stata ANOVA Interaction term differences

The following two statements produce different results.

/* DV: "price" e.g., from 0 to 100 */
/* IV: "treatmentA", "treatmentB" both binary variables */

/* statement 1 */
anova price treatmentA##treatmentB

/* statement 2 */
generate A_x_B = treatmentA * treatmentB
anova price treatmentA treatmentB A_x_B


Do the two statements not represent the same model?

Any suggestions, why generating an interaction term by myself and including it into an ANOVA produces different results than using the built-in option to include interaction terms?

. anova price treatmentA##treatmentB

Number of obs =    2160     R-squared     =  0.0481
Root MSE      = 3.62039     Adj R-squared =  0.0468

Source |  Partial SS    df       MS           F     Prob > F
---------------------+----------------------------------------------------
Model |  1427.66343     3  475.887809      36.31     0.0000
|
treatmentA |  590.372454     1  590.372454      45.04     0.0000
treatmentB |  786.261343     1  786.261343      59.99     0.0000
treatmentA#treatme~B |  258.622454     1  258.622454      19.73     0.0000
|
Residual |  28259.1958  2156  13.1072337
---------------------+----------------------------------------------------
Total |  29686.8593  2159  13.7502822

. generate A_x_B = treatmentA * treatmentB
. anova price treatmentA treatmentB A_x_B

Number of obs =    2160     R-squared     =  0.0481
Root MSE      = 3.62039     Adj R-squared =  0.0468

Source |  Partial SS    df       MS           F     Prob > F
------------+----------------------------------------------------
Model |  1427.66343     3  475.887809      36.31     0.0000
|
treatmentA |       33.75     1       33.75       2.57     0.1087
treatmentB |  730.034722     1  730.034722      55.70     0.0000
A_x_B |  258.622454     1  258.622454      19.73     0.0000
|
Residual |  28259.1958  2156  13.1072337
------------+----------------------------------------------------
Total |  29686.8593  2159  13.7502822

• How different are we talking?
– D3L
Jul 24 '14 at 3:15
• The output is way different. Although not the overall result but individual variables
– mmu
Jul 24 '14 at 14:05

Your variable A_x_B is generated and stored as a float (7 decimal places more-or-less), by your command, but using the built in option to generate an interation term, would create a double, thus is evaluated exactly (or at least to double accuracy).