Skip to contents

oneway_anova() helps you determine if average values differ across three or more groups. For example, does average income vary by education level? Or is customer satisfaction different across regions?

Think of it as:

  • An extension of t-test for more than two groups

  • A way to test if group membership affects outcomes

  • A tool to identify meaningful group differences

The test tells you:

  • Whether at least one group is different from the others

  • How much variation is explained by group membership

  • Which variance assumption fits your data best

Usage

oneway_anova(
  data,
  ...,
  group,
  weights = NULL,
  var.equal = TRUE,
  conf.level = 0.95
)

Arguments

data

Your survey data (a data frame or tibble)

...

The numeric variables you want to analyze. You can list multiple variables or use helpers like starts_with("income")

group

The categorical variable that defines your groups (e.g., education, region, age_group). Must have at least 3 groups for ANOVA.

weights

Optional survey weights for population-representative results

var.equal

Should we assume all groups have similar variance? (Default: TRUE)

  • TRUE: Standard ANOVA (assumes equal variances)

  • FALSE: Welch's ANOVA (allows unequal variances)

conf.level

Confidence level for intervals (Default: 0.95 = 95%)

Value

ANOVA results showing whether groups differ, including:

  • F-statistic and p-value (are groups different?)

  • Effect sizes (how much do groups matter?)

  • Group statistics (means and standard deviations)

  • Both standard and Welch ANOVA results Use summary() for the full SPSS-style output with toggleable sections.

Details

Understanding the Results

P-value: If p < 0.05, at least one group average is different

  • p < 0.001: Very strong evidence of group differences

  • p < 0.01: Strong evidence of group differences

  • p < 0.05: Moderate evidence of group differences

  • p ≥ 0.05: No significant group differences found

Effect Sizes (How much do groups matter?):

  • Eta-squared: Proportion of variance explained by groups

    • < 0.01: Negligible effect

    • 0.01-0.06: Small effect

    • 0.06-0.14: Medium effect

    • 0.14 or higher: Large effect

  • Omega-squared: More conservative estimate (usually preferred)

When to Use This

Use ANOVA when:

  • You have one numeric outcome (income, satisfaction score, etc.)

  • You have one categorical grouping variable with 3+ groups

  • You want to know if group averages differ

  • Your data is roughly normally distributed within groups

Choosing Variance Assumptions

  • Standard ANOVA (var.equal = TRUE): Use when group variances are similar

  • Welch's ANOVA (var.equal = FALSE): Use when group variances differ or you're unsure

  • The function shows both results for comparison

What Comes Next?

If ANOVA is significant:

  1. Look at group means to see the pattern

  2. Use tukey_test() to find which specific groups differ

  3. Consider effect sizes to judge practical importance

Tips for Success

  • Check that each group has sufficient observations (ideally 20+)

  • Look at both p-values and effect sizes

  • Use Welch's ANOVA if group sizes are very unequal

  • Follow up with post-hoc tests to identify specific differences

  • Welch's robust test for equality of means

References

Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.). Lawrence Erlbaum Associates.

Welch, B. L. (1951). On the comparison of several mean values: an alternative approach. Biometrika, 38(3/4), 330-336.

Olejnik, S., & Algina, J. (2003). Generalized eta and omega squared statistics: measures of effect size for some common research designs. Psychological Methods, 8(4), 434-447.

See also

aov for the base R ANOVA function.

oneway.test for Welch's ANOVA.

tukey_test for post-hoc pairwise comparisons.

levene_test for testing homogeneity of variances.

summary.oneway_anova for detailed output with toggleable sections.

Other hypothesis_tests: ancova(), binomial_test(), chi_square(), chisq_gof(), factorial_anova(), fisher_test(), friedman_test(), kruskal_wallis(), mann_whitney(), mcnemar_test(), t_test(), wilcoxon_test()

Examples

# Load required packages and data
library(dplyr)
data(survey_data)

# Basic one-way ANOVA (comparing across education levels)
survey_data %>%
  oneway_anova(life_satisfaction, group = education)
#> One-Way ANOVA: life_satisfaction by education
#>   F(3, 2417) = 67.096, p < 0.001 ***, eta2 = 0.077 (medium), N = 2421

# Multiple dependent variables
survey_data %>%
  oneway_anova(life_satisfaction, trust_government, group = education)
#> One-Way ANOVA: life_satisfaction by education
#>   F(3, 2417) = 67.096, p < 0.001 ***, eta2 = 0.077 (medium), N = 2421
#> One-Way ANOVA: trust_government by education
#>   F(3, 2350) = 0.431, p = 0.731 , eta2 = 0.001 (negligible), N = 2354

# Using tidyselect helpers
survey_data %>%
  oneway_anova(starts_with("trust_"), group = education)
#> One-Way ANOVA: trust_government by education
#>   F(3, 2350) = 0.431, p = 0.731 , eta2 = 0.001 (negligible), N = 2354
#> One-Way ANOVA: trust_media by education
#>   F(3, 2363) = 0.902, p = 0.439 , eta2 = 0.001 (negligible), N = 2367
#> One-Way ANOVA: trust_science by education
#>   F(3, 2394) = 0.605, p = 0.612 , eta2 = 0.001 (negligible), N = 2398

# Weighted analysis
survey_data %>%
  oneway_anova(income, group = education, weights = sampling_weight)
#> One-Way ANOVA: income by education [Weighted]
#>   F(3, 2197) = 462.325, p < 0.001 ***, eta2 = 0.387 (large), N = 2201

# Grouped analysis (separate ANOVA for each region)
survey_data %>%
  group_by(region) %>%
  oneway_anova(life_satisfaction, group = education)
#> [region = 1]
#> One-Way ANOVA: life_satisfaction by education
#>   F(3, 461) = 6.950, p < 0.001 ***, eta2 = 0.043 (small), N = 465
#> [region = 2]
#> One-Way ANOVA: life_satisfaction by education
#>   F(3, 1952) = 62.153, p < 0.001 ***, eta2 = 0.087 (medium), N = 1956

# Unequal variances (Welch's ANOVA)
survey_data %>%
  oneway_anova(income, group = education, var.equal = FALSE)
#> One-Way ANOVA: income by education
#>   F(3, 2182) = 466.494, p < 0.001 ***, eta2 = 0.391 (large), N = 2186

# Store results for post-hoc analysis
result <- survey_data %>%
  oneway_anova(life_satisfaction, group = education)

# Follow up with post-hoc tests
result %>% tukey_test()
#> Tukey HSD Post-Hoc Test Results
#> -------------------------------
#> 
#> - Dependent variable: life_satisfaction
#> - Grouping variable: education
#> - Confidence level: 95.0%
#>   Family-wise error rate controlled using Tukey HSD
#> 
#> 
#> --- life_satisfaction ---
#> 
#> Tukey Results:
#> ---------------------------------------------------------------------------------- 
#>                                 Comparison Difference Lower CI Upper CI p-value
#>     Intermediate Secondary-Basic Secondary      0.497    0.344    0.649   <.001
#>         Academic Secondary-Basic Secondary      0.649    0.496    0.802   <.001
#>                 University-Basic Secondary      0.843    0.666    1.019   <.001
#>  Academic Secondary-Intermediate Secondary      0.153   -0.010    0.316   0.075
#>          University-Intermediate Secondary      0.346    0.161    0.531   <.001
#>              University-Academic Secondary      0.193    0.008    0.379   0.037
#>  Sig
#>  ***
#>  ***
#>  ***
#>     
#>  ***
#>    *
#> ---------------------------------------------------------------------------------- 
#> 
#> 
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05
#> 
#> Interpretation:
#> - Positive differences: First group > Second group
#> - Negative differences: First group < Second group
#> - Confidence intervals not containing 0 indicate significant differences
#> - p-values are adjusted for multiple comparisons (family-wise error control)
result %>% levene_test()  # Check homogeneity of variances
#> 
#> Levene's Test for Homogeneity of Variance 
#> ------------------------------------------
#> 
#> - Grouping variable: education
#> - Center: mean
#> 
#> 
#> --- life_satisfaction ---
#> 
#> Levene's Test Results:
#> -------------------------------------------------------------------- 
#>           Variable F_statistic df1  df2 p_value sig        Conclusion
#>  life_satisfaction      31.634   3 2417       0 *** Variances unequal
#> -------------------------------------------------------------------- 
#> 
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05
#> 
#> Interpretation:
#> - p > 0.05: Variances are homogeneous (equal variances assumed)
#> - p <= 0.05: Variances are heterogeneous (equal variances NOT assumed)
#> 
#> Recommendation based on Levene test:
#> - Use Welch's t-test (unequal variances)

# --- Three-layer output ---
result              # compact one-line overview
#> One-Way ANOVA: life_satisfaction by education
#>   F(3, 2417) = 67.096, p < 0.001 ***, eta2 = 0.077 (medium), N = 2421
summary(result)     # full detailed output with all sections
#> One-Way ANOVA Results
#> ---------------------
#> 
#> - Dependent variable: life_satisfaction
#> - Grouping variable: education
#> - Confidence level: 95.0%
#>   Null hypothesis: All group means are equal
#>   Alternative hypothesis: At least one group mean differs
#> 
#> 
#> --- life_satisfaction ---
#> 
#> Descriptive Statistics by Group:
#>   Basic Secondary: mean = 3.204, sd = 1.243, n = 809
#>   Intermediate Secondary: mean = 3.701, sd = 1.112, n = 618
#>   Academic Secondary: mean = 3.853, sd = 0.998, n = 607
#>   University: mean = 4.047, sd = 0.957, n = 387
#> 
#> ANOVA Results:
#> -------------------------------------------------------------------------------- 
#>          Source Sum_Squares   df Mean_Square      F p_value sig
#>  Between Groups     247.347    3      82.449 67.096   <.001   1
#>   Within Groups    2970.080 2417       1.229                   
#>           Total    3217.428 2420                               
#> -------------------------------------------------------------------------------- 
#> 
#> Assumption Tests:
#> ---------------- 
#>  Assumption Statistic df1  df2 p_value sig
#>       Welch    64.489   3 1229   <.001 ***
#> 
#> Effect Sizes:
#> ------------ 
#>           Variable Eta_Squared Epsilon_Squared Omega_Squared Effect_Size
#>  life_satisfaction       0.077           0.076         0.076      medium
#> 
#> 
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05
#> 
#> Effect Size Interpretation:
#> - Eta-squared: Proportion of variance explained (biased upward)
#> - Epsilon-squared: Less biased than eta-squared
#> - Omega-squared: Unbiased estimate (preferred for publication)
#> - Small effect: eta-squared ~ 0.01, Medium effect: eta-squared ~ 0.06, Large effect: eta-squared ~ 0.14
#> 
#> Post-hoc tests: Use tukey_test() for pairwise comparisons
summary(result, descriptives = FALSE)  # hide group statistics
#> One-Way ANOVA Results
#> ---------------------
#> 
#> - Dependent variable: life_satisfaction
#> - Grouping variable: education
#> - Confidence level: 95.0%
#>   Null hypothesis: All group means are equal
#>   Alternative hypothesis: At least one group mean differs
#> 
#> 
#> --- life_satisfaction ---
#> 
#> 
#> ANOVA Results:
#> -------------------------------------------------------------------------------- 
#>          Source Sum_Squares   df Mean_Square      F p_value sig
#>  Between Groups     247.347    3      82.449 67.096   <.001   1
#>   Within Groups    2970.080 2417       1.229                   
#>           Total    3217.428 2420                               
#> -------------------------------------------------------------------------------- 
#> 
#> Assumption Tests:
#> ---------------- 
#>  Assumption Statistic df1  df2 p_value sig
#>       Welch    64.489   3 1229   <.001 ***
#> 
#> Effect Sizes:
#> ------------ 
#>           Variable Eta_Squared Epsilon_Squared Omega_Squared Effect_Size
#>  life_satisfaction       0.077           0.076         0.076      medium
#> 
#> 
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05
#> 
#> Effect Size Interpretation:
#> - Eta-squared: Proportion of variance explained (biased upward)
#> - Epsilon-squared: Less biased than eta-squared
#> - Omega-squared: Unbiased estimate (preferred for publication)
#> - Small effect: eta-squared ~ 0.01, Medium effect: eta-squared ~ 0.06, Large effect: eta-squared ~ 0.14
#> 
#> Post-hoc tests: Use tukey_test() for pairwise comparisons