Analysis of Variance

Example usage


anova(ToothGrowth, dep = 'len', factors = c('dose', 'supp'))

#  ───────────────────────────────────────────────────────────────────────
#                 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
#  ───────────────────────────────────────────────────────────────────────


data the data as a data frame
dep a string naming the dependent variable from data, variable must be numeric
factors a vector of strings naming the fixed factors from data
modelTerms a list of character vectors describing the terms to go into the model
ss '1', '2' or '3' (default), the sum of squares to use
effectSize one or more of 'eta', 'partEta', or 'omega'; use η², partial η², and ω² effect sizes, respectively
contrasts a list of lists specifying the factor and type of contrast to use, one of 'deviation', 'simple', 'difference', 'helmert', 'repeated' or 'polynomial'
plotHAxis a string naming the variable placed on the horizontal axis of the plot
plotSepLines a string naming the variable represented as separate lines on the plot
plotSepPlots a string naming the variable to separate over to form multiple plots
postHoc a list of terms to perform post-hoc tests on
postHocCorr one or more of 'none', 'tukey', 'scheffe', 'bonf', or 'holm'; provide no, Tukey, Scheffe, Bonferroni, and Holm Post Hoc corrections respectively
descStats TRUE or FALSE (default), provide descriptive statistics
homo TRUE or FALSE (default), perform homogeneity tests
qq TRUE or FALSE (default), provide a Q-Q plot of residuals
plotError 'none', 'ci' (default), or 'se'. Use no error bars, use confidence intervals, or use standard errors on the plots, respectively
ciWidth a number between 50 and 99.9 (default: 95) specifying the confidence interval width


A results object containing:

results$main a table
results$assump$homo a table
results$contrasts an array of tables
results$postHoc an array of tables
results$desc a table
results$descPlot an image
results$descPlots an array of images

Tables can be converted to data frames with asDF or For example:


Elements in arrays can be accessed with [[n]]. For example:

results$contrasts[[1]] # accesses the first element