UK-based online statistics and data analysis support for USA, UK, and international clients. No exams, no impersonation, no fabricated data.
ANOVA Family

Factorial ANOVA: Two-Way ANOVA Formula, Interaction, Main Effects, SPSS, Python, R and Excel Guide

Two-Way ANOVA, Main Effects, Interaction, Cell Means and Residual Diagnostics Factorial ANOVA: Two-Way ANOVA Formula, Interaction, Main Effects, SPSS, Python, R and Excel Guide Factorial ANOVA...

Statistics guide Ethical learning support SPSS/R/Python/Excel friendly
Factorial ANOVA: Two-Way ANOVA Formula, Interaction, Main Effects, SPSS, Python, R and Excel Guide

Two-Way ANOVA, Main Effects, Interaction, Cell Means and Residual Diagnostics

Factorial ANOVA: Two-Way ANOVA Formula, Interaction, Main Effects, SPSS, Python, R and Excel Guide

Factorial ANOVA is used when one numeric outcome is compared across two or more categorical factors at the same time. In this worked example, the outcome is G3 final grade, and the two factors are studytime and sex. The analysis tests the main effect of studytime, the main effect of sex, and the studytime × sex interaction. The guide includes interaction plots, cell means, main-effect charts, p-value decision charts, effect-size summary, residual diagnostics, SPSS output, Python report, R report, Excel workflow and APA reporting.

Advertisement
Google AdSense top placement reserved here

Quick Answer: Factorial ANOVA Result

The worked Factorial ANOVA example shows that studytime is the only clearly significant factor in the supplied p-value charts. The studytime effect is far below the alpha line, while sex has p ≈ 0.07362 and the studytime × sex interaction has p ≈ 0.08323. Because both of those p values are above 0.05, sex and the interaction are not statistically significant at the 5% level in this chart set.

The interaction plot is still important because the two lines are not perfectly parallel. Female mean G3 increases steadily from studytime group 1 to group 4, while male mean G3 rises from group 1 to group 3 and then drops in group 4. The plotted interaction pattern is visible, but the p-value chart shows that it is not strong enough to be declared statistically significant at alpha = 0.05.

MethodFactorial ANOVA
OutcomeG3
Factor 1studytime
Factor 2sex

Studytime effectSignificant
Sex effectp ≈ .07362
Interactionp ≈ .08323
Alpha.05

Lowest cell mean1 | M = 10.59
Highest cell mean4 | F = 14.19
Female mean12.25
Male mean11.41

Final interpretation: The factorial ANOVA supports a significant main effect of studytime on G3. The chart set does not support a statistically significant sex main effect or a statistically significant studytime × sex interaction at alpha = .05. The interaction plot should still be discussed because the male and female lines behave differently at studytime group 4, but the p-value decision does not cross the significance threshold.

Important reporting point: In factorial ANOVA, the interaction must be checked before relying only on main effects. A visible interaction pattern can appear in the chart even when the formal interaction p value is above .05. Report both the visual pattern and the statistical decision.

Table of Contents

  1. What Is Factorial ANOVA?
  2. Factorial ANOVA Formula
  3. Main Effect and Interaction Hypotheses
  4. Dataset and Variables Used
  5. Python Chart-by-Chart Interpretation
  6. R Chart-by-Chart Validation
  7. SPSS Output and Report PDFs
  8. SPSS, R, Python and Excel Workflows
  9. Code Blocks for Factorial ANOVA
  10. APA Reporting Wording
  11. Common Mistakes
  12. When to Use Factorial ANOVA
  13. Downloads and Resources
  14. Related Guides
  15. FAQs

What Is Factorial ANOVA?

Factorial ANOVA is an ANOVA model that studies more than one categorical factor at the same time. A simple one-way ANOVA tests one factor. A factorial ANOVA tests two or more factors and also checks whether the effect of one factor depends on another factor.

In this example, the two factors are studytime and sex. The dependent variable is G3 final grade. The model tests whether mean G3 differs across studytime groups, whether mean G3 differs between female and male students, and whether the studytime pattern changes depending on sex.

The supplied charts show a clear studytime pattern. Female students rise from about 11.19 in studytime group 1 to about 14.19 in group 4. Male students rise from about 10.59 in group 1 to about 13.59 in group 3, then drop to about 11.36 in group 4. This produces a visible non-parallel pattern in the interaction plot, but the formal interaction p value is above .05.

Simple definition: Factorial ANOVA tests main effects and interactions. A main effect asks whether one factor changes the outcome overall. An interaction asks whether the effect of one factor changes across levels of another factor.

Factorial ANOVA should be interpreted with ANOVA in Python, ANOVA in R, ANOVA in SPSS, ANOVA Assumptions, ANOVA Effect Size, Effect Size, Cohen’s F Formula, P Value, and Null and Alternative Hypothesis.

Factorial ANOVA Formula

A two-way factorial ANOVA with two factors can be written as a model with two main effects and one interaction term.

Y = μ + A + B + A×B + ε

In this example, Y is G3 final grade, A is studytime, B is sex, and A×B is the studytime × sex interaction. The error term represents variation in G3 not explained by the two factors and their interaction.

Factorial ANOVA for This Example

G3 = μ + studytime + sex + studytime×sex + ε

This model tests three ANOVA sources: studytime, sex, and studytime × sex. The p-value charts show that studytime is statistically significant, while sex and the interaction are above the .05 alpha line.

F Test Formula

F = MSeffect / MSerror

Each source in the factorial ANOVA table has its own F statistic. The model compares the mean square for that source with the error mean square. A small p value means the source explains more variation than expected from error variation alone.

Effect Size Formula

Partial η² = SSeffect / (SSeffect + SSerror)

The effect-size charts use partial eta squared to compare the relative practical size of the studytime effect, sex effect and interaction. The visual scale shows very small values, so the effect-size summary should be interpreted as a supporting diagnostic rather than a large-effect claim.

ANOVA SourceQuestion AnsweredChart DecisionPractical Meaning
studytimeDoes mean G3 differ across studytime groups?SignificantStudytime is associated with G3 differences.
sexDoes mean G3 differ between female and male students overall?Not significant at .05Female mean is higher, but p ≈ .07362 is above .05.
studytime × sexDoes the studytime pattern differ by sex?Not significant at .05The plot is non-parallel, but p ≈ .08323 is above .05.

Main Effect and Interaction Hypotheses

Factorial ANOVA tests more than one hypothesis in the same model. The main effect of studytime, the main effect of sex and the studytime × sex interaction each have their own null and alternative hypothesis.

EffectNull HypothesisAlternative HypothesisDecision in This Output
studytimeAll studytime marginal means are equal.At least one studytime marginal mean differs.Reject H0.
sexFemale and male marginal means are equal.Female and male marginal means differ.Do not reject H0 at .05.
studytime × sexThe studytime pattern is the same for females and males.The studytime pattern differs by sex.Do not reject H0 at .05.

Decision for this example: The factorial ANOVA supports the main effect of studytime. It does not support the sex main effect or the studytime × sex interaction at alpha = .05. The safest report is that studytime is statistically significant, while sex and the interaction show visible patterns but do not reach the .05 significance threshold.

Dataset and Variables Used

The worked example uses a student performance dataset. The dependent variable is G3 final grade. The first factor is studytime, with four levels. The second factor is sex, with female and male groups. The model compares cell means for every studytime × sex combination.

Variable or OutputRoleWhy It MattersWhere It Appears
G3Dependent variableFinal grade outcome being compared.All mean, cell mean and residual charts.
studytimeFactor 1Main learning-time factor.Main effect and interaction plots.
sexFactor 2Second grouping factor.Main effect of sex and interaction plot.
studytime × sexInteractionTests whether studytime effect changes by sex.Interaction plot and p-value summary.
cell meansGroup combination meansShows each studytime-sex combination.Cell means chart.
residualsModel diagnosticsChecks fit and assumption patterns.Residuals vs fitted and Q-Q plot.

For supporting concepts, review Descriptive Statistics, Mean Median and Mode, Standard Deviation, Variance, Standard Error, Confidence Interval, Box Plot Interpretation, and Histogram Interpretation.

Advertisement
Google AdSense middle placement reserved here

Python Chart-by-Chart Interpretation

The Python charts show the first factorial ANOVA workflow. They explain the interaction plot, studytime-sex cell means, main effects, p-value decision, partial eta squared summary and residual diagnostics.

Python Chart 1: Interaction Plot

Factorial ANOVA Python interaction plot for studytime and sex predicting G3
Python interaction plot showing mean G3 across studytime levels for female and male students.

This interaction plot compares female and male mean G3 across studytime groups. The female line rises steadily from group 1 through group 4. The male line rises from group 1 to group 3, then drops sharply at group 4.

The two lines are not parallel, which visually suggests that the relationship between studytime and G3 may differ by sex. The strongest visual difference appears at studytime group 4, where the female mean is high while the male mean is much lower.

The p-value chart must be used with this visual pattern. The interaction plot shows a possible interaction shape, but the formal interaction p value is about 0.08323, which is above the .05 threshold. The correct conclusion is visible non-parallel lines without a statistically significant interaction at alpha = .05.

Python Chart 2: Cell Means

Factorial ANOVA Python cell means for studytime by sex
Python cell means chart showing mean G3 for each studytime and sex combination.

This chart ranks the mean G3 values for each combination of studytime and sex. The lowest cell mean is 1 | M = 10.59, followed by 1 | F = 11.19. The highest cell mean is 4 | F = 14.19, followed by 3 | M = 13.59 and 3 | F = 13.12.

The cell means show why the interaction plot is not perfectly parallel. Female students continue upward into studytime group 4, while male students peak in studytime group 3 and then drop in group 4.

This chart gives the best practical explanation of the model. Factorial ANOVA is not only about marginal means; it also studies the individual combinations of the factors.

Python Chart 3: Main Effect of Studytime

Factorial ANOVA Python main effect of studytime
Python chart showing overall mean G3 across studytime levels.

This chart shows the overall mean G3 for each studytime level after averaging across sex. The means increase from group 1 to group 3 and remain high in group 4. The visible values are about 10.84 for group 1, 12.09 for group 2 and about 13.23 for group 3, with group 4 near the same high range.

The studytime pattern is the strongest result in the factorial ANOVA. The p-value summary places the studytime effect far below the alpha line, so studytime is statistically significant.

This chart should be used to explain the main finding. Higher studytime levels are associated with higher G3 means, even after the model includes sex and the interaction term.

Python Chart 4: Main Effect of Sex

Factorial ANOVA Python main effect of sex
Python chart showing overall mean G3 for female and male students.

This chart compares overall mean G3 between female and male students. The female mean is about 12.25, while the male mean is about 11.41. The chart therefore shows a higher average G3 for female students.

The p-value summary shows that this difference does not reach the .05 threshold. The sex p value is about 0.07362, which is above .05.

The correct interpretation is that the sample shows a visible female-male mean difference, but the factorial ANOVA does not declare the sex main effect statistically significant at the 5% level.

Python Chart 5: P-Value Decision Summary

Factorial ANOVA Python p-value decision summary
Python p-value decision chart comparing studytime, sex and interaction p values with alpha .05.

This chart compares the p values for the factorial ANOVA sources with the alpha line at 0.05. The studytime p value is extremely small and is placed far to the left of the alpha line. The sex p value is about 0.07362, and the interaction p value is about 0.08323.

The chart gives the formal decision. Studytime is statistically significant because its p value is below .05. Sex and the studytime × sex interaction are not statistically significant because their p values are above .05.

This chart is the most important statistical decision summary. It prevents over-reading the interaction plot by showing that the visible non-parallel pattern is not significant at alpha .05.

Python Chart 6: Effect Size Summary

Factorial ANOVA Python effect size summary with partial eta squared
Python effect-size chart showing partial eta squared context for studytime, sex and interaction.

This chart summarizes the practical size of the factorial ANOVA effects with partial eta squared. The bars are shown on a wide partial eta squared scale, so the effects appear very small visually.

The effect-size chart should be read with the p-value chart. Studytime is statistically significant, while sex and the interaction do not cross the .05 threshold. The practical-size summary does not support a large-effect claim for any source.

The safest reporting approach is to state the significance decisions first, then report effect sizes as supporting information. In this example, the studytime effect is the meaningful source to discuss, while sex and the interaction are not significant at alpha .05.

Python Chart 7: Residuals vs Fitted Values

Factorial ANOVA Python residuals versus fitted values
Python residuals versus fitted values chart for factorial ANOVA diagnostics.

This residual plot shows residuals against fitted values from the factorial ANOVA model. The points appear in vertical groups because each fitted value corresponds to a studytime-sex cell mean. Most residuals are centered around the zero line.

Several large negative residuals appear below the main cloud, especially around fitted values near 11.2, 11.9 and 12.2. These cases represent students whose observed G3 scores were much lower than their fitted cell mean.

The diagnostic conclusion is that the model captures the group structure, but some low-score cases create a negative residual tail. These cases should be mentioned in the assumptions section rather than ignored.

Python Chart 8: Residual Q-Q Plot

Factorial ANOVA Python residual Q-Q plot
Python Q-Q plot showing residual normality context for the factorial ANOVA model.

The Q-Q plot compares the residual distribution with a normal reference line. The middle part of the residual distribution is closer to the reference line, but the lower tail moves far below the line.

The largest departures occur on the negative side, matching the residuals-versus-fitted chart. This shows that a small group of students scored far below the model’s fitted cell mean.

The Q-Q plot does not change the main studytime result, but it adds diagnostic context. The final report should state that the main effect of studytime is significant while residual diagnostics show lower-tail departures from normality.

R Chart-by-Chart Validation

The R validation charts repeat the same factorial ANOVA workflow in a second software environment. They confirm the interaction shape, cell means, main effects, p-value decisions, effect-size context and residual diagnostic pattern.

R Chart 1: Interaction Plot

Factorial ANOVA R interaction plot
R validation interaction plot showing mean G3 across studytime levels by sex.

This R chart confirms the non-parallel pattern between female and male students. The female line increases steadily across studytime groups, while the male line rises through group 3 and then falls in group 4.

The visible shape is important, but it must still be interpreted with the interaction p value. The supplied p-value chart reports the interaction above .05, so the visual interaction is not statistically significant at alpha .05.

This chart validates the Python interaction plot and supports the same conclusion: discuss the visible pattern, but do not claim a statistically significant interaction.

R Chart 2: Cell Means

Factorial ANOVA R cell means
R validation chart showing mean G3 for each studytime-sex cell.

This R chart confirms the cell mean ranking. The lowest mean appears for 1 | M = 10.59, while the highest mean appears for 4 | F = 14.19. The values for studytime group 3 are high for both sexes, with male students around 13.59 and female students around 13.12.

The chart makes the interaction pattern easier to understand. The female group reaches its highest value at studytime group 4, while the male group peaks at group 3 and then falls at group 4.

In reporting, this chart should be used after the interaction plot because it shows the exact cell combinations responsible for the plotted line pattern.

R Chart 3: Main Effect of Studytime

Factorial ANOVA R main effect of studytime
R validation chart showing overall mean G3 across studytime levels.

This R chart confirms the main effect of studytime. The mean G3 is about 10.84 at studytime group 1 and about 12.09 at group 2, then rises into the higher range for groups 3 and 4.

This pattern matches the p-value decision chart, where studytime is the significant source. The visible increase in means explains why the studytime main effect is the central result of the factorial ANOVA.

The final interpretation should emphasize studytime first. It is the factor that clearly crosses the statistical decision threshold in the supplied chart set.

R Chart 4: Main Effect of Sex

Factorial ANOVA R main effect of sex
R validation chart showing overall mean G3 for female and male students.

This R chart confirms that the female mean G3 is higher than the male mean G3. The female mean is about 12.25, and the male mean is about 11.41.

The p-value decision chart shows that this difference is not statistically significant at the .05 level because the sex p value is about 0.07362. The visible difference is therefore reported as a sample pattern, not as a statistically significant main effect.

This chart supports careful wording. Do not write that sex significantly affects G3 at .05; write that female students had a higher sample mean, but the main effect of sex did not reach the .05 significance level.

R Chart 5: P-Value Decision Summary

Factorial ANOVA R p-value decision summary
R validation p-value decision chart comparing ANOVA sources with alpha .05.

This R chart confirms the same decision pattern. Studytime is below the alpha threshold, while sex is about 0.07362 and the studytime × sex interaction is about 0.08323.

The chart includes the .05 alpha line, making the decision direct. Only effects to the left of that line are statistically significant at the 5% level.

The R validation result agrees with the Python workflow: studytime is significant, sex is not significant at .05, and the interaction is not significant at .05.

R Chart 6: Effect Size Summary

Factorial ANOVA R effect size summary
R validation effect-size chart showing partial eta squared context.

This R chart displays the partial eta squared context for the factorial ANOVA sources. The bars are visually tiny on the chart scale, so the effect sizes should not be presented as large.

The effect-size chart should be interpreted alongside the p-value chart. Studytime is the statistically supported effect, while sex and the interaction do not reach significance at alpha .05.

In final reporting, effect sizes should be used as supporting context. The strongest practical message remains the significant studytime effect and the non-significant sex and interaction tests.

R Chart 7: Residuals vs Fitted Values

Factorial ANOVA R residuals versus fitted values
R validation residuals versus fitted values chart.

The R residuals-versus-fitted chart confirms the same vertical-band pattern as the Python chart. The fitted values represent studytime-sex cell means, and most residuals are centered around zero.

Several negative residuals fall well below the main pattern. These cases represent students whose observed G3 scores were much lower than the fitted value for their cell.

The chart supports a balanced diagnostic statement. The factorial ANOVA model is useful for the studytime effect, but the residual diagnostics show lower-tail cases that should be mentioned.

R Chart 8: Residual Q-Q Plot

Factorial ANOVA R residual Q-Q plot
R validation Q-Q plot for factorial ANOVA residuals.

The R Q-Q plot confirms that the central residuals are closer to the reference line, while the lower tail departs from the line. This matches the Python Q-Q plot.

The lower-tail departure means some observations are much lower than the model expects from their studytime-sex cell. This should be reported as a diagnostic limitation or assumption note.

The Q-Q plot does not remove the significant studytime effect. It adds context: the model finds a clear studytime difference, while residual normality is not perfect because of low-tail cases.

SPSS Output and Report PDFs

The supplied report files provide downloadable support for the Factorial ANOVA workflow. The Python report, R report and SPSS output PDF should be linked in the resources section and used as verification files for the WordPress article.

Download Factorial ANOVA Python Report PDF

Download Factorial ANOVA R Report PDF

Download Factorial ANOVA SPSS Output PDF

Output Items to Read

Output ItemWhat It ShowsHow It Is UsedReporting Meaning
Interaction plotStudytime pattern by sex.Checks whether lines are parallel.Visible non-parallel pattern, but interaction p is above .05.
Cell meansMean G3 for each studytime-sex combination.Explains the interaction pattern.Highest cell is 4 | F, lowest cell is 1 | M.
Main effect of studytimeOverall mean G3 by studytime.Tests studytime after averaging across sex.Significant effect.
Main effect of sexOverall mean G3 by sex.Tests sex after averaging across studytime.Not significant at .05.
P-value summaryStudytime, sex and interaction p values.Gives formal decisions.Only studytime is significant at .05.
Residual diagnosticsResiduals vs fitted and Q-Q plot.Checks model assumptions.Lower-tail departures should be reported.

Report interpretation summary: The Factorial ANOVA report supports a significant studytime main effect on G3. The sex main effect and studytime × sex interaction are not significant at alpha .05 in the supplied p-value summaries. The residual diagnostics show lower-tail cases, so the final report should include an assumptions note.

Advertisement
Google AdSense in-content placement reserved here

SPSS, R, Python and Excel Workflows for Factorial ANOVA

The same Factorial ANOVA workflow can be reproduced in SPSS, R, Python and Excel. The key steps are to define the two categorical factors, fit a model with main effects and interaction, read the ANOVA table, inspect interaction and cell means, report effect sizes and check residual diagnostics.

SPSS Workflow

StepSPSS Menu or SyntaxPurpose
Open dataFile > Open > DataLoad G3, studytime and sex.
Run modelAnalyze > General Linear Model > UnivariateFit factorial ANOVA.
Set dependent variableDependent Variable: G3Define the numeric outcome.
Set fixed factorsFixed Factors: studytime and sexDefine categorical factors.
Request interactionModel: Full factorialTest studytime, sex and studytime × sex.
Request plotsPlots: studytime on horizontal axis, sex as separate linesCreate interaction plot.
Request effect sizeOptions > Estimates of effect sizeDisplay partial eta squared.
Export outputOUTPUT EXPORTSave SPSS output PDF.

R Workflow

StepR ActionPurpose
Read dataread.csv("dataset.csv")Load the dataset.
Convert factorsas.factor(studytime) and as.factor(sex)Ensure categorical treatment.
Fit modelaov(G3 ~ studytime * sex)Run factorial ANOVA.
Read ANOVA tablesummary(model)Get main effects and interaction p values.
Cell meansaggregate(G3 ~ studytime + sex)Explain interaction pattern.
Diagnosticsplot(model)Check residuals and Q-Q plot.

Python Workflow

StepPython ActionPurpose
Read datapandas.read_csv()Load dataset.
Fit modelols("G3 ~ C(studytime) * C(sex)")Fit factorial ANOVA.
ANOVA tablesm.stats.anova_lm(model, typ=2)Read main effects and interaction.
Cell meansgroupby(["studytime","sex"])Calculate cell means.
Effect sizePartial eta squared formulaCompare source sizes.
DiagnosticsResidual plots and Q-Q plotCheck model assumptions.

Excel Workflow

Excel TaskFormula or ToolPurpose
Arrange dataRows for studytime and columns for sexCreate two-factor layout.
Run ANOVAData Analysis ToolPak > ANOVA: Two-Factor With ReplicationRun factorial ANOVA when cells have repeated observations.
Read rows effectRows sourceUsually one factor such as studytime.
Read columns effectColumns sourceUsually second factor such as sex.
Read interactionInteraction sourceTest whether factor effects depend on each other.
DecisionCompare p values with alphaReject H0 when p < .05.

Code Blocks for Factorial ANOVA

SPSS Syntax for Factorial ANOVA

* Factorial ANOVA / Two-Way ANOVA in SPSS.
* Dependent variable: G3.
* Fixed factors: studytime and sex.

TITLE "Factorial ANOVA: G3 by Studytime and Sex".

UNIANOVA G3 BY studytime sex
  /METHOD=SSTYPE(3)
  /INTERCEPT=INCLUDE
  /PLOT=PROFILE(studytime*sex)
  /PRINT=DESCRIPTIVE ETASQ HOMOGENEITY
  /EMMEANS=TABLES(studytime)
  /EMMEANS=TABLES(sex)
  /EMMEANS=TABLES(studytime*sex)
  /CRITERIA=ALPHA(.05)
  /DESIGN=studytime sex studytime*sex.

OUTPUT EXPORT
  /CONTENTS EXPORT=VISIBLE
  /PDF DOCUMENTFILE="factorial_anova_output.pdf".

Python Code for Factorial ANOVA

import pandas as pd
import numpy as np
import statsmodels.api as sm
from statsmodels.formula.api import ols

df = pd.read_csv("dataset.csv")

df["G3"] = pd.to_numeric(df["G3"], errors="coerce")
df["studytime"] = df["studytime"].astype("category")
df["sex"] = df["sex"].astype("category")

df_model = df.dropna(subset=["G3", "studytime", "sex"]).copy()

# Factorial ANOVA model with main effects and interaction
model = ols("G3 ~ C(studytime) * C(sex)", data=df_model).fit()

anova_table = sm.stats.anova_lm(model, typ=2)
print(anova_table)

# Cell means
cell_means = (
    df_model
    .groupby(["studytime", "sex"])["G3"]
    .agg(["count", "mean", "std"])
    .reset_index()
)
print(cell_means)

# Main effects
studytime_means = df_model.groupby("studytime")["G3"].mean()
sex_means = df_model.groupby("sex")["G3"].mean()

print("Studytime means")
print(studytime_means)

print("Sex means")
print(sex_means)

# Partial eta squared
ss_error = anova_table.loc["Residual", "sum_sq"]

effect_sizes = {}
for source in anova_table.index:
    if source != "Residual":
        ss_effect = anova_table.loc[source, "sum_sq"]
        effect_sizes[source] = ss_effect / (ss_effect + ss_error)

print("Partial eta squared")
print(effect_sizes)

# Residual diagnostics
df_model["fitted"] = model.fittedvalues
df_model["residual"] = model.resid

print(df_model[["G3", "studytime", "sex", "fitted", "residual"]].head())

R Code for Factorial ANOVA

df <- read.csv("dataset.csv")

df$G3 <- as.numeric(df$G3)
df$studytime <- as.factor(df$studytime)
df$sex <- as.factor(df$sex)

df_model <- na.omit(df[, c("G3", "studytime", "sex")])

# Factorial ANOVA model
model <- aov(G3 ~ studytime * sex, data = df_model)

summary(model)

# Cell means
aggregate(G3 ~ studytime + sex, data = df_model, FUN = function(x) {
  c(n = length(x), mean = mean(x), sd = sd(x))
})

# Main effect means
aggregate(G3 ~ studytime, data = df_model, mean)
aggregate(G3 ~ sex, data = df_model, mean)

# Diagnostic values
df_model$fitted <- fitted(model)
df_model$residuals <- residuals(model)

# Residual diagnostics
plot(model)

# Optional interaction plot
interaction.plot(
  x.factor = df_model$studytime,
  trace.factor = df_model$sex,
  response = df_model$G3,
  fun = mean,
  xlab = "studytime",
  ylab = "Mean G3",
  trace.label = "sex"
)

Excel Formulas and Tool Steps for Factorial ANOVA

Excel Tool:
Data > Data Analysis > ANOVA: Two-Factor With Replication

Use this when:
- Factor 1 = studytime
- Factor 2 = sex
- Outcome = G3
- Each studytime-sex cell has repeated observations

Decision rule:
If p-value for rows < alpha, factor 1 is significant.
If p-value for columns < alpha, factor 2 is significant.
If p-value for interaction < alpha, interaction is significant.

Alpha:
0.05

Example interpretation from this output:
studytime = significant
sex = not significant at .05
studytime × sex = not significant at .05

Cell mean:
=AVERAGE(cell_range)

Cell standard deviation:
=STDEV.S(cell_range)

Decision formula:
=IF(p_value<0.05,"Reject H0","Fail to reject H0")

APA Reporting Wording

When reporting Factorial ANOVA, report the main effects and interaction separately. Do not only report the strongest effect. The reader needs to know whether each factor and their interaction were significant.

APA-style report: A factorial ANOVA was used to examine the effects of studytime and sex on G3 final grade. The main effect of studytime was statistically significant, indicating that mean G3 differed across studytime levels. The main effect of sex was not statistically significant at alpha = .05, p ≈ .07362. The studytime × sex interaction was also not statistically significant at alpha = .05, p ≈ .08323. Cell means showed that female students in studytime group 4 had the highest mean G3, while male students in studytime group 1 had the lowest mean G3.

Short reporting version: The factorial ANOVA showed a significant main effect of studytime on G3, while the sex main effect and the studytime × sex interaction were not significant at the .05 level.

Common Mistakes

MistakeWhy It Is WrongCorrect Practice
Ignoring the interactionFactorial ANOVA is designed to test whether factors work together.Always report main effects and interaction.
Calling a visible interaction significantNon-parallel lines can appear even when p > .05.Use the p-value decision with the plot.
Reporting only studytimeThe model also tests sex and studytime × sex.Report all ANOVA sources.
Confusing cell means with main effectsCell means are factor combinations; main effects are marginal means.Interpret both separately.
Ignoring residual diagnosticsANOVA depends on reasonable residual and variance behavior.Check residuals vs fitted, Q-Q plot, Levene Test and Brown-Forsythe Test.
Skipping effect sizeSignificance does not show practical size.Add ANOVA Effect Size, Effect Size or Cohen’s F Formula.

When to Use Factorial ANOVA

Use Factorial ANOVA when the dependent variable is numeric and the research question includes two or more categorical factors. It is especially useful when the analyst wants to test both main effects and interactions in the same model.

SituationUse Factorial ANOVA?Reporting Note
One numeric outcome and two categorical factorsYesReport both main effects and interaction.
Testing whether factor effects depend on each otherYesUse interaction term.
Only one categorical factorNoUse one-way ANOVA.
One numeric covariate includedUse ANCOVASee the ANCOVA guide.
Repeated-measures factor includedUse repeated-measures ANOVACheck sphericity and corrections.

For related guides, see ANOVA in Python, ANOVA in R, ANOVA in SPSS, ANOVA Assumptions, ANOVA Effect Size, Balanced ANOVA, Brown Forsythe ANOVA, ANCOVA, and T Test vs ANOVA.

Downloads and Resources for Factorial ANOVA

Use these resources to reproduce the Factorial ANOVA workflow. The Python report, R report and SPSS output PDF are included as verification files. Script and workbook placeholders can be replaced after the final files are uploaded to the WordPress Media Library.

FAQs About Factorial ANOVA

What is Factorial ANOVA?

Factorial ANOVA is an ANOVA model that tests two or more categorical factors and their interaction effects on one numeric outcome.

What is the difference between one-way ANOVA and Factorial ANOVA?

One-way ANOVA tests one categorical factor. Factorial ANOVA tests two or more factors and can test interactions between them.

What was the main result in this example?

The main effect of studytime was significant. The main effect of sex and the studytime × sex interaction were not significant at alpha .05.

Was the interaction significant?

No. The interaction p value was about 0.08323, which is above .05. The plot shows non-parallel lines, but the formal interaction test was not significant at the 5% level.

What was the sex main-effect result?

The female mean G3 was higher than the male mean G3 in the sample, but the sex p value was about 0.07362, so the effect was not significant at alpha .05.

What cell had the highest mean G3?

The highest cell mean was studytime group 4 for female students, with mean G3 about 14.19.

What cell had the lowest mean G3?

The lowest cell mean was studytime group 1 for male students, with mean G3 about 10.59.

Can Factorial ANOVA be done in Excel?

Yes. Excel Data Analysis ToolPak has ANOVA: Two-Factor With Replication, which can be used when the data are arranged in a two-factor layout with repeated observations.

What should be checked before reporting Factorial ANOVA?

Check group means, interaction plot, p-value summary, effect size, residuals versus fitted values, Q-Q plot and equal-variance assumption checks.

How do I report this Factorial ANOVA in APA style?

A concise report is: A factorial ANOVA showed a significant main effect of studytime on G3, while the sex main effect and studytime × sex interaction were not significant at the .05 level.

Need help applying this to your own data?

Salar Cafe can help interpret output, clean datasets, review assumptions, build dashboards and explain statistical results ethically.

Need help interpreting your data analysis results?

Contact Salar Cafe
Engr. Muhammad Yar Saqib author profile photo

Engr. Muhammad Yar Saqib

WhatsApp Get Data Analysis Help