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 η^2) and their confidence intervals (CIs). 90% CIs for partial η^2 (two-sided) 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?

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 = 2,
  nsmall = digits,
  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).

Two ways to specify this argument:

  • Use ":" to specify the range of variables: e.g., "A1B1:A2B3" (similar to the SPSS syntax "TO" and the order of variables matters)

  • Use a character vector to specify variable names: e.g., c("Cond1", "Cond2", "Cond3")

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. Default is "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. Default is "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? Default is 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, nsmall

Number of decimal places of output. Default is 2.

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.

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.

See Also

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"))


#### 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 0.8.0 Index]