Section author: Ravi Selker, Jonathon Love, Damian Dropmann
ANOVA (ANOVA)
Description
The Analysis of Variance (ANOVA) is used to explore the relationship between a continuous dependent variable, and one or more categorical explanatory variables.
Usage
ANOVA(
data,
dep,
factors = NULL,
effectSize = NULL,
modelTest = FALSE,
modelTerms = NULL,
ss = "3",
homo = FALSE,
norm = FALSE,
qq = FALSE,
contrasts = NULL,
postHoc = NULL,
postHocCorr = list("tukey"),
postHocES = list(),
postHocEsCi = FALSE,
postHocEsCiWidth = 95,
emMeans = list(list()),
emmPlots = TRUE,
emmPlotData = FALSE,
emmPlotError = "ci",
emmTables = FALSE,
emmWeights = TRUE,
ciWidthEmm = 95,
formula
)
Arguments
|
the data as a data frame |
|
the dependent variable from |
|
the explanatory factors in |
|
one or more of |
|
|
|
a formula describing the terms to go into the model (not necessary when providing a formula, see examples) |
|
|
|
|
|
|
|
|
|
a list of lists specifying the factor and type of contrast to use, one of |
|
a formula containing the terms to perform post-hoc tests on (see the examples) |
|
one or more of |
|
a possible value of |
|
|
|
a number between 50 and 99.9 (default: 95), the width of confidence intervals for the post-hoc effect sizes |
|
a formula containing the terms to estimate marginal means for (see the examples) |
|
|
|
|
|
|
|
|
|
|
|
a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the estimated marginal means |
|
(optional) the formula to use, see the examples |
Details
ANOVA assumes that the residuals are normally distributed, and that the variances of all groups are equal. If one is unwilling to assume that the variances are equal, then a Welch’s test can be used instead (however, the Welch’s test does not support more than one explanatory factor). Alternatively, if one is unwilling to assume that the data is normally distributed, a non-parametric approach (such as Kruskal-Wallis) can be used.
Output
A results object containing:
|
a table of ANOVA results |
|
the underlying |
|
a table of homogeneity tests |
|
a table of normality tests |
|
a q-q plot |
|
an array of contrasts tables |
|
an array of post-hoc tables |
|
an array of the estimated marginal means plots + tables |
Tables can be converted to data frames with asDF or as.data.frame(). For example:
results$main$asDF
as.data.frame(results$main)
Examples
data('ToothGrowth')
ANOVA(formula = len ~ dose * supp, data = ToothGrowth)
#
# ANOVA
#
# ANOVA
# -----------------------------------------------------------------------
# Sum of Squares df Mean Square F p
# -----------------------------------------------------------------------
# dose 2426 2 1213.2 92.00 < .001
# supp 205 1 205.4 15.57 < .001
# dose:supp 108 2 54.2 4.11 0.022
# Residuals 712 54 13.2
# -----------------------------------------------------------------------
#
ANOVA(
formula = len ~ dose * supp,
data = ToothGrowth,
emMeans = ~ supp + dose:supp, # est. marginal means for supp and dose:supp
emmPlots = TRUE, # produce plots of those marginal means
emmTables = TRUE) # produce tables of those marginal means