Learn R Programming

ez (version 1.3)

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
	, sid
	, within = NULL
	, between = NULL
)

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.
sid
.() 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 independent variables that are manipulated within-Ss.
between
Optional .() object specifying one or more columns in data that contain independent variables that are manipulated between-Ss.

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 are present, a data frame containing the results of Mauchly's test for Sphericity.
  • 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 sid, 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 sid, within or between.

See Also

ezPerm, ezPlot, ezStats

Examples

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

#Show summaries of the ANT data.
head(ANT)
str(ANT)
summary(ANT)

#Compute some useful statistics per cell.
cell_stats = ddply(
	.data = ANT
	, .variables = .( sid , group , cue , flanker )
	, .fun <- function(x){
		#Compute error rate as percent.
		error_rate = (1-mean(x$acc))*100
		#Compute mean RT (only accurate trials).
		mean_rt = mean(x$rt[x$acc==1])
		#Compute SD RT (only accurate trials).
		sd_rt = sd(x$rt[x$acc==1])
		return(c(error_rate=error_rate,mean_rt=mean_rt,sd_rt=sd_rt))
	}
)

#Run an ANOVA on the mean_rt data.
mean_rt_anova = ezANOVA(
	data = cell_stats
	, dv = .(mean_rt)
	, sid = .(sid)
	, within = .(cue,flanker)
	, 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 = cell_stats
	, dv = .(mean_rt)
	, sid = .(sid)
	, within = .(cue,flanker)
)

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

#Run a purely between-Ss ANOVA on the mean_rt data.
##Note how ezANOVA automatically collapses the unspecified within-Ss data.
mean_rt_anova3 = ezANOVA(
	data = cell_stats
	, dv = .(mean_rt)
	, sid = .(sid)
	, between = .(group)
)

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

Run the code above in your browser using DataLab