Learn R Programming

lsr (version 1.0.0)

etaSquared: Effect size for ANOVAs

Description

Calculates eta-squared and partial eta-squared effect sizes for an analysis of variance.

Usage

etaSquared(x, type = 2, anova = FALSE)

Value

A matrix with one row per term in the ANOVA model and columns for eta-squared (eta.sq) and partial eta-squared (eta.sq.part). If anova = TRUE, additional columns show the sums of squares, mean squares, degrees of freedom, F-statistics, and p-values.

Arguments

x

An aov object, as returned by aov.

type

Which type of sums of squares to use: 1 for Type I, 2 for Type II (the default), or 3 for Type III. Type II is recommended for most unbalanced designs.

anova

Set to TRUE to include the full ANOVA table alongside the effect sizes. Defaults to FALSE.

Details

Calculates eta-squared and partial eta-squared, two commonly used measures of effect size in analysis of variance. The input x should be an ANOVA fitted with aov.

For unbalanced designs, Type II sums of squares (type = 2) are recommended and are the default, consistent with the Anova function in the car package. Type I (type = 1) matches the output of anova but tests hypotheses that are often not of interest in unbalanced designs. Type III (type = 3) is also available.

See Also

Examples

Run this code
outcome <- c(1.4, 2.1, 3.0, 2.1, 3.2, 4.7, 3.5, 4.5, 5.4)
treatment1 <- factor(c(1, 1, 1, 2, 2, 2, 3, 3, 3))

# one-way ANOVA
anova1 <- aov(outcome ~ treatment1)
summary(anova1)
etaSquared(anova1)

# include the full ANOVA table
etaSquared(anova1, anova = TRUE)

# two-way ANOVA
treatment2 <- factor(c(1, 2, 3, 1, 2, 3, 1, 2, 3))
anova2 <- aov(outcome ~ treatment1 + treatment2)
etaSquared(anova2)

Run the code above in your browser using DataLab