0
$\begingroup$

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?

edit: some additional output:

. 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   
$\endgroup$
2
  • $\begingroup$ How different are we talking? $\endgroup$ – D3L Jul 24 '14 at 3:15
  • $\begingroup$ The output is way different. Although not the overall result but individual variables $\endgroup$ – mmu Jul 24 '14 at 14:05
0
$\begingroup$

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).

$\endgroup$
2
  • $\begingroup$ The differences don't look (to me) like differences due to float point precision, since the interaction term itself is the same. Other variables differ. $\endgroup$ – mmu Jul 24 '14 at 16:28
  • $\begingroup$ noted, this is weird, I'll have a look and get back $\endgroup$ – D3L Jul 25 '14 at 0:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.