MANOVA {bruceR} R Documentation

## Multi-factor ANOVA.

### Description

Multi-factor ANOVA (between-subjects, within-subjects, 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 (between-subjects and/or within-subjects). Almost all results you need will be displayed together, including effect sizes (partial \eta^2) and their confidence intervals (CIs). 90% CIs for partial \eta^2 (two-sided) are reported, following Steiger (2004). In addition to partial \eta^2, it also reports generalized \eta^2, following Olejnik & Algina (2003).

How to prepare your data and specify the arguments of MANOVA?

• Wide-format data (one person in one row, and repeated measures in multiple columns):

Betweem-subjects design

MANOVA(data=, dv=, between=, ...)

Within-subjects design

MANOVA(data=, dvs=, dvs.pattern=, within=, ...)

Mixed design

MANOVA(data=, dvs=, dvs.pattern=, between=, within=, ...)

• Long-format data (one person in multiple rows, and repeated measures in one column):

Betweem-subjects design

(not applicable)

Within-subjects design

MANOVA(data=, subID=, dv=, within=, ...)

Mixed design

MANOVA(data=, subID=, dv=, between=, within=, ...)

### Usage

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,
file = NULL
)


### Arguments

 data Data frame. Both wide-format and long-format are supported. subID Subject ID (the column name). Only necessary for long-format data. dv Dependent variable. For wide-format data, dv only can be used for between-subjects designs. For within-subjects and mixed designs, please use dvs and dvs.pattern. For long-format data, dv is the outcome variable. dvs Repeated measures. Only for wide-format data (within-subjects or mixed designs). Can be: "start:stop" to specify the range of variables (sensitive to the order of variables): e.g., "A1B1:A2B3" is matched to all variables in the data between "A1B1" and "A2B3" a character vector to directly specify variables (insensitive to the order of variables): e.g., c("Cond1", "Cond2", "Cond3") or cc("Cond1, Cond2, Cond3") See cc for its usage. dvs.pattern If you use dvs, you should also specify the pattern of variable names using regular expression. Examples: "Cond(.)" extracts levels from "Cond1", "Cond2", "Cond3", ... You may rename the factor using the within argument (e.g., within="Condition") "X(..)Y(..)" extracts levels from "X01Y01", "X02Y02", "XaaYbc", ... "X(.+)Y(.+)" extracts levels from "X1Y1", "XaYb", "XaY002", ... Tips on regular expression: "(.)" extracts any single character (number, letter, and other symbols) "(.+)" extracts >= 1 character(s) "(.*)" extracts >= 0 character(s) "([0-9])" extracts any single number "([a-z])" extracts any single letter More information: Link 1 (in English) and Link 2 (in Chinese) between Between-subjects factor(s). Multiple variables should be included in a character vector c(). within Within-subjects factor(s). Multiple variables should be included in a character vector c(). covariate Covariates. Multiple variables should be included in a character vector c(). ss.type Type of sums of squares (SS) for ANOVA. Defaults to "III". Possible values are "II", "III", 2, or 3. 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. Defaults to "none". If Mauchly's test of sphericity is significant, you may set it to "GG" (Greenhouse-Geisser) or "HF" (Huynh-Feldt). aov.include Include the aov object in the returned object? Defaults to FALSE, as suggested by afex::aov_ez() (please see the include_aov argument in this help page, which provides a detailed explanation). If TRUE, you should also specify model.type="univariate" in EMMEANS. digits Number of decimal places of output. Defaults to 3. file File name of MS Word (.doc).

### Details

If observations are not uniquely identified in user-defined long-format 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().

### Value

A result object (list) returned by afex::aov_ez(), along with several other elements: between, within, data.wide, data.long.

### Interaction Plot

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.

### References

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, bruceR-demodata

### Examples

#### Between-Subjects 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)

#### Within-Subjects 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 within-subjects 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")



[Package bruceR version 2023.9 Index]