Learn R Programming

ez (version 2.0-0)

ezANOVA: Function to perform a factorial ANOVA

Description

This function provides easy analysis of data from factorial experiments, including purely within-Ss designs (a.k.a. "repeated measures"), purely between-Ss designs, and mixed within-and-between-Ss designs, yielding ANOVA results and assumption checks.

Usage

ezANOVA(
    data
    , dv
    , wid
    , within = NULL
    , between = NULL
    , observed = NULL
    , diff = NULL
    , reverse_diff = FALSE
)

Arguments

data
Data frame containing the data to be analyzed.
dv
.() object specifying the column in data that contains the dependent variable. Values in this column must be numeric.
wid
.() object specifying the column in data that contains the variable specifying the case/Ss identifier.
within
Optional .() object specifying one or more columns in data that contain predictor variables that are manipulated (or observed) within-Ss.
between
Optional .() object specifying one or more columns in data that contain predictor variables that are manipulated (or observed) between-Ss.
observed
Optional .() object specifying one or more columns in data that contain predictor variables that are observed variables (i.e. not manipulated). The presence of observed variables affects the computation of the generalized eta-squared measure
diff
Optional .() object specifying a 2-level within-Ss varbiable to collapse to a difference score.
reverse_diff
Optional boolean to trigger reversal of the difference collapse requested by diff.

Value

  • A list containing one or more of the following components:
  • ANOVAA data frame containing the ANOVA results.
  • Mauchly's Test for SphericityIf any within-Ss variables with >2 levels are present, a data frame containing the results of Mauchly's test for Sphericity. Only reported for effects >2 levels because sphericity necessarily holds for effects with only 2 levels.
  • Sphericity CorrectionsIf any within-Ss variables are present, a data frame containing the Greenhouse-Geisser & Huynh-Feldt epsilon values, and corresponding corrected p-values.
  • Levene's Test for HomgeneityIf the design is purely between-Ss, a data frame containing the results of Levene's test for Homgeneity of variance.

Warning

The statistical computing in ezAnova() is driven by the Anova function from the car package, using the univariate Type-II test. If there are too few Ss in the data set for Anova to compute its MANOVA, ezAnova() will revert to using aov for computing the ANOVA, in which case no assumption tests are provided. When assumption tests are provided via Anova, Huynh-Feldt corrected p-values where the Huynh-Feldt epsilon >1 will use 1 as the correction epsilon.

Details

While within and between are both optional, at least one column of data must be provided to either within or between. Any numeric or character variables in data that are specified as either wid, within or between will be converted to a factor with a warning. Prior to running, dv is collapsed to a mean for each cell defined by the combination of wid, within or between.

References

Bakeman, R. (2005). Recommended effect size statistics for repeated measures designs. Behavior Research Methods, 37 (3), 379-384.

See Also

ANT, ANT2, ezANOVA, ezBoot, ezCor, ezDesign, ezPerm, ezPlot, ezPlotBoot, ezPrecis, ezStats

Examples

Run this code
#Read in the ANT data (see ?ANT).
data(ANT)
head(ANT)
ezPrecis(ANT)


#Run an ANOVA on the mean correct RT data.
mean_rt_anova = ezANOVA(
    data = ANT[ANT$error==0,]
    , dv = .(rt)
    , wid = .(subnum)
    , within = .(cue,flank)
    , between = .(group)
)

#Show the ANOVA & assumption tests.
print(mean_rt_anova)

#Run an ANOVA on the mean_rt data, ignoring group.
mean_rt_anova2 = ezANOVA(
    data = ANT[ANT$error==0,]
    , dv = .(rt)
    , wid = .(subnum)
    , within = .(cue,flank)
)

#Show the ANOVA & assumption tests.
print(mean_rt_anova2)

#Run a purely between-Ss ANOVA on the mean_rt data.
mean_rt_anova3 = ezANOVA(
    data = ANT[ANT$error==0,]
    , dv = .(rt)
    , wid = .(subnum)
    , between = .(group)
)

#Show the ANOVA & assumption tests.
print(mean_rt_anova3)

Run the code above in your browser using DataLab