StatsCalculators.com

Two-Way ANOVA

Created:October 15, 2024
Last Updated:January 25, 2025

The Two-Way ANOVA (Analysis of Variance) Calculator helps you analyze the effects of two independent variables (factors) on a dependent variable. It tests whether there are significant differences between the means of different groups, considering both main effects and interaction effects between factors. It provides comprehensive statistical analysis including F-statistics, p-values, and effect sizes to help you interpret the relationships between your variables. To learn about the data format required and test this calculator, click here to populate the sample data.

Calculator

1. Load Your Data

2. Select Columns & Options

Learn More

Two-Way ANOVA

Definition

Two-Way ANOVA examines the influence of two categorical independent variables on one continuous dependent variable. It tests for main effects of each factor and their interaction effect. It helps determine if there are significant differences between group means in a dataset.
  • Factors: The independent categorical variables.
  • Levels: The groups or categories within each factor.
  • Interaction: Determines whether the effect of one factor depends on the level of the other factor.

Formulas

Total Sum of Squares Decomposition:

SSTotal=SSFactorA+SSFactorB+SSInteraction+SSErrorSS_{Total} = SS_{FactorA} + SS_{FactorB} + SS_{Interaction} + SS_{Error}

SSTotal=i=1aj=1b(XijXˉ)2SS_{Total} = \sum_{i=1}^{a} \sum_{j=1}^{b} (X_{ij} - \bar{X})^2where Xˉ\bar{X} is the grand mean

SSFactorA=bi=1a(Xˉi.Xˉ)2SS_{FactorA} = b \sum_{i=1}^{a} (\bar{X}_{i.} - \bar{X})^2whereXˉi.\bar{X}_{i.} is the mean of level ii of Factor A, and bb is the number of levels in Factor B.

SSFactorB=aj=1b(Xˉ.jXˉ)2SS_{FactorB} = a \sum_{j=1}^{b} (\bar{X}_{.j} - \bar{X})^2where Xˉ.j\bar{X}_{.j} is the mean of level $j$ of Factor B, and $a$ is the number of levels in Factor A.

SSInteraction=i=1aj=1b(XˉijXˉi.Xˉ.j+Xˉ)2SS_{Interaction} = \sum_{i=1}^{a} \sum_{j=1}^{b} (\bar{X}_{ij} - \bar{X}_{i.} - \bar{X}_{.j} + \bar{X})^2

Where:

  • SSFactorASS_{FactorA} = Sum of Squares for Factor A, df=a1df = a - 1 where aa is the number of levels in Factor A
  • SSFactorBSS_{FactorB} = Sum of Squares for Factor B, df=b1df = b - 1 where bb is the number of levels in Factor B
  • SSInteractionSS_{Interaction} = Sum of Squares for interaction with df=(a1)(b1)df = (a - 1)(b - 1)
  • SSErrorSS_{Error} = Residual Sum of Squares, df=Nabdf = N - a*b

Mean Square:

MS=SSdfMS = \frac{SS}{df}

F-Statistic for each factor:

fFactor=MSFactorMSErrorf_{Factor} = \frac{MS_{Factor}}{MS_{Error}}

F-statistics are calculated separately for each factor and interaction effect

Key Assumptions

Independence: Observations must be independent
Normality: Residuals should be normally distributed
Homoscedasticity: Equal variances across groups

Practical Example

Step 1: State the Data

Weight loss study examining effects of diet and exercise:

Raw Data:
DietExerciseWeight Loss (pounds)
Low-fatYes8, 10, 9
Low-fatNo6, 7, 8
High-fatYes5, 7, 6
High-fatNo3, 4, 5
Summary Statistics:
DietExerciseMeanN
Low-fatYes9.003
Low-fatNo7.003
High-fatYes6.003
High-fatNo4.003
Step 2: State Hypotheses

Main Effects:

  • Diet: H0:α1=α2=0H_0: \alpha_1 = \alpha_2 = 0
  • Exercise: H0:β1=β2=0H_0: \beta_1 = \beta_2 = 0

Interaction:

  • H0:(αβ)ij=0H_0: (\alpha\beta)_{ij} = 0 for all i,ji,j
Step 3: Calculate Test Statistics
SourcedfSSMSFp-value
Diet127.027.027.00.000826
Exercise112.012.012.00.008516
Diet:Exercise10.00.00.01.0000
Residuals881
Step 4: Draw Conclusions
  • Significant main effect of Diet (p = 0.000826)
  • Significant main effect of Exercise (p = 0.008516)
  • No significant interaction effect (p = 1.0000)
  • Diet and Exercise appear to have a significant effect on weight loss at α=0.05\alpha = 0.05
  • The interaction between Diet and Exercise are not statistically significant

Effect Size

Partial Eta-squared:

ηp2=SSFactorSSFactor+SSError\eta^2_p = \frac{SS_{Factor}}{SS_{Factor} + SS_{Error}}

For the example above,

  • Diet: ηp2=2727+8=0.77\eta^2_p = \frac{27}{27+8} = 0.77 (large effect)
  • Exercise: ηp2=1212+8=0.60\eta^2_p = \frac{12}{12+8} = 0.60 (large effect)
  • Interaction: ηp2=0.00\eta^2_p = 0.00 (no effect)

Verification

Related Calculators