View source: R/bruceRstats_3_manova.R
MANOVA  R Documentation 
Multifactor ANOVA (betweensubjects, withinsubjects, and mixed designs), with and without covariates (ANCOVA).
This function is based on and extends afex::aov_ez()
.
You only need to specify the data, dependent variable(s), and factors
(betweensubjects and/or withinsubjects).
Almost all results you need will be displayed together,
including effect sizes (partial η^2) and their confidence intervals (CIs).
90% CIs for partial η^2 (twosided) are reported, following Steiger (2004).
In addition to partial η^2, it also reports generalized η^2, following Olejnik & Algina (2003).
How to prepare your data and specify the arguments of MANOVA
?
Wideformat data (one person in one row, and repeated measures in multiple columns):
MANOVA(data=, dv=, between=, ...)
MANOVA(data=, dvs=, dvs.pattern=, within=, ...)
MANOVA(data=, dvs=, dvs.pattern=, between=, within=, ...)
Longformat data (one person in multiple rows, and repeated measures in one column):
(not applicable)
MANOVA(data=, subID=, dv=, within=, ...)
MANOVA(data=, subID=, dv=, between=, within=, ...)
MANOVA( data, subID = NULL, dv = NULL, dvs = NULL, dvs.pattern = NULL, between = NULL, within = NULL, covariate = NULL, ss.type = "III", sph.correction = "none", aov.include = FALSE, digits = 3, nsmall = digits, file = NULL )
data 
Data frame. Both wideformat and longformat are supported. 
subID 
Subject ID (the column name). Only necessary for longformat data. 
dv 
Dependent variable.

dvs 
Repeated measures. Only for wideformat data (withinsubjects or mixed designs). Can be:

dvs.pattern 
If you use Examples:
Tips on regular expression:

between 
Betweensubjects factor(s). Multiple variables should be included in a character vector 
within 
Withinsubjects factor(s). Multiple variables should be included in a character vector 
covariate 
Covariates. Multiple variables should be included in a character vector 
ss.type 
Type of sums of squares (SS) for ANOVA. Default is 
sph.correction 
[Only for repeated measures with >= 3 levels] Sphericity correction method for adjusting the degrees of freedom (df) when the sphericity assumption is violated. Default is 
aov.include 
Include the 
digits, nsmall 
Number of decimal places of output. Default is 
file 
File name of MS Word ( 
If observations are not uniquely identified in userdefined longformat data,
the function takes averages across those multiple observations for each case.
In technical details, it specifies fun_aggregate=mean
in afex::aov_ez()
and values_fn=mean
in tidyr::pivot_wider()
.
A result object (list) returned by
afex::aov_ez()
,
along with several other elements:
between
, within
,
data.wide
, data.long
.
You can save the returned object and use the emmeans::emmip()
function
to create an interaction plot (based on the fitted model and a formula specification).
For usage, please see the help page of emmeans::emmip()
.
It returns an object of class ggplot
, which can be easily modified and saved using ggplot2
syntax.
Olejnik, S., & Algina, J. (2003). Generalized eta and omega squared statistics: Measures of effect size for some common research designs. Psychological Methods, 8(4), 434–447.
Steiger, J. H. (2004). Beyond the F test: Effect size confidence intervals and tests of close fit in the analysis of variance and contrast analysis. Psychological Methods, 9(2), 164–182.
TTEST
, EMMEANS
, bruceRdemodata
#### BetweenSubjects Design #### between.1 MANOVA(between.1, dv="SCORE", between="A") between.2 MANOVA(between.2, dv="SCORE", between=c("A", "B")) between.3 MANOVA(between.3, dv="SCORE", between=c("A", "B", "C")) ## How to create an interaction plot using `emmeans::emmip()`? ## See help page for its usage: ?emmeans::emmip() m = MANOVA(between.2, dv="SCORE", between=c("A", "B")) emmip(m, ~ A  B, CIs=TRUE) emmip(m, ~ B  A, CIs=TRUE) emmip(m, B ~ A, CIs=TRUE) emmip(m, A ~ B, CIs=TRUE) #### WithinSubjects Design #### within.1 MANOVA(within.1, dvs="A1:A4", dvs.pattern="A(.)", within="A") ## the same: MANOVA(within.1, dvs=c("A1", "A2", "A3", "A4"), dvs.pattern="A(.)", within="MyFactor") # renamed the withinsubjects factor within.2 MANOVA(within.2, dvs="A1B1:A2B3", dvs.pattern="A(.)B(.)", within=c("A", "B")) within.3 MANOVA(within.3, dvs="A1B1C1:A2B2C2", dvs.pattern="A(.)B(.)C(.)", within=c("A", "B", "C")) #### Mixed Design #### mixed.2_1b1w MANOVA(mixed.2_1b1w, dvs="B1:B3", dvs.pattern="B(.)", between="A", within="B") MANOVA(mixed.2_1b1w, dvs="B1:B3", dvs.pattern="B(.)", between="A", within="B", sph.correction="GG") mixed.3_1b2w MANOVA(mixed.3_1b2w, dvs="B1C1:B2C2", dvs.pattern="B(.)C(.)", between="A", within=c("B", "C")) mixed.3_2b1w MANOVA(mixed.3_2b1w, dvs="B1:B2", dvs.pattern="B(.)", between=c("A", "C"), within="B") #### Other Examples #### data.new = mixed.3_1b2w names(data.new) = c("Group", "Cond_01", "Cond_02", "Cond_03", "Cond_04") MANOVA(data.new, dvs="Cond_01:Cond_04", dvs.pattern="Cond_(..)", between="Group", within="Condition") # rename the factor # ?afex::obk.long MANOVA(afex::obk.long, subID="id", dv="value", between=c("treatment", "gender"), within=c("phase", "hour"), cov="age", sph.correction="GG")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.