ancova | R Documentation |
The Analysis of Covariance (ANCOVA) is used to explore the relationship between a continuous dependent variable, one or more categorical explanatory variables, and one or more continuous explanatory variables (or covariates). It is essentially the same analysis as ANOVA, but with the addition of covariates.
ancova(data, dep, factors = NULL, covs = 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)
data |
the data as a data frame |
dep |
the dependent variable from |
factors |
the explanatory factors in |
covs |
the explanatory covariates (not necessary when providing a formula, see examples) |
effectSize |
one or more of |
modelTest |
|
modelTerms |
a formula describing the terms to go into the model (not necessary when providing a formula, see examples) |
ss |
|
homo |
|
norm |
|
qq |
|
contrasts |
a list of lists specifying the factor and type of contrast
to use, one of |
postHoc |
a formula containing the terms to perform post-hoc tests on (see the examples) |
postHocCorr |
one or more of |
postHocES |
a possible value of |
postHocEsCi |
|
postHocEsCiWidth |
a number between 50 and 99.9 (default: 95), the width of confidence intervals for the post-hoc effect sizes |
emMeans |
a formula containing the terms to estimate marginal means for (see the examples) |
emmPlots |
|
emmPlotData |
|
emmPlotError |
|
emmTables |
|
emmWeights |
|
ciWidthEmm |
a number between 50 and 99.9 (default: 95) specifying the confidence interval width for the estimated marginal means |
formula |
(optional) the formula to use, see the examples |
A results object containing:
results$main | a table of ANCOVA results | ||||
results$model | The underlying aov object |
||||
results$assump$homo | a table of homogeneity tests | ||||
results$assump$norm | a table of normality tests | ||||
results$assump$qq | a q-q plot | ||||
results$contrasts | an array of contrasts tables | ||||
results$postHoc | an array of post-hoc tables | ||||
results$emm | an array of the estimated marginal means plots + tables | ||||
results$residsOV | an output | ||||
Tables can be converted to data frames with asDF
or as.data.frame
. For example:
results$main$asDF
as.data.frame(results$main)
data('ToothGrowth')
ancova(formula = len ~ supp + dose, data = ToothGrowth)
#
# ANCOVA
#
# ANCOVA
# -----------------------------------------------------------------------
# Sum of Squares df Mean Square F p
# -----------------------------------------------------------------------
# supp 205 1 205.4 11.4 0.001
# dose 2224 1 2224.3 124.0 < .001
# Residuals 1023 57 17.9
# -----------------------------------------------------------------------
#
ancova(
formula = len ~ supp + dose,
data = ToothGrowth,
postHoc = ~ supp,
emMeans = ~ supp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.