MANOVA {bruceR}R Documentation

Multi-factor ANOVA.

Description

Easily perform multi-factor ANOVA (between-subjects, within-subjects, and mixed designs), with or without covariates (ANCOVA). Print results to R Console (and MS Word).

This function is based on and extends the afex::aov_ez() function. 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 in an elegant manner, including effect sizes (partial η^2) and their confidence intervals (CIs). 90% CIs for partial η^2 are reported, following the suggestion by Steiger (2004).

Usage

MANOVA(
  data,
  subID = NULL,
  dv = NULL,
  dvs = NULL,
  dvs.pattern = "",
  between = NULL,
  within = NULL,
  covariate = NULL,
  sph.correction = "none",
  nsmall = 2,
  file = NULL
)

Arguments

data

Data frame. Both long-format and wide-format can be used.

  • If using long-format data, please also set subID.

  • If using wide-format data (i.e., one subject occupies one row, and repeated measures occupy multiple columns), the function can automatically transform the data into long-format.

subID

Subject ID.

  • If using long-format data, you should set the subject ID.

  • If using wide-format data, no need to set this parameter.

dv

Variable name of dependent variable.

  • If using long-format data, then dv is the outcome variable.

  • If using wide-format data, then dv can only be used for complete between-subjects design. For designs with repeated measures, please use dvs and dvs.pattern.

dvs

[only for "wide-format" data and designs with repeated measures]

Variable names of repeated measures.

  • You can use ":" to specify a range of variables: e.g., "A1B1:A2B3" (similar to the SPSS syntax "TO"; the variables should be put in order)

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

dvs.pattern

[only for "wide-format" data and designs with repeated measures]

If you set dvs, you must also set the pattern of variable names by using regular expressions.

Examples:

  • "Cond(.)" can extract levels from "Cond1", "Cond2", "Cond3", ...

    You can rename the factor name by using within: e.g., within="Condition"

  • "X(..)Y(..)" can extract levels from "X01Y01", "X02Y02", "XaaYbc", ...

  • "X(.+)Y(.+)" can extract levels from "X1Y1", "XaYb", "XaY002", ...

Tips on regular expression:

  • "(.)" extracts any single character (can be number, letter, or other symbols)

  • "(.+)" extracts >= 1 character(s)

  • "(.*)" extracts >= 0 character(s)

  • "([0-9])" extracts any single number

  • "([a-z])" extracts any single letter

  • each pair of "()" extracts levels for each factor

between

Between-subjects factors. Character string (e.g., "A") or vector (e.g., c("A", "B")). Default is NULL.

within

Within-subjects factors. Character string (e.g., "A") or vector (e.g., c("A", "B")). Default is NULL.

covariate

Covariates (if necessary). Character string (e.g., "age") or vector (e.g., c("gender", "age", "edu")). Default is NULL.

sph.correction

[only effective for repeated measures with >= 3 levels]

Sphericity correction method to adjust 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).

nsmall

Number of decimal places of output. Default is 2.

file

File name of MS Word (.doc).

Value

A result object returned by afex::aov_ez().

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. doi: 10.1037/1082-989X.8.4.434

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. doi: 10.1037/1082-989X.9.2.164

See Also

EMMEANS, bruceR-demodata

Examples

#### Between-Subjects Design ####

between.1
MANOVA(data=between.1, dv="SCORE", between="A")

between.2
MANOVA(data=between.2, dv="SCORE", between=c("A", "B"))

between.3
MANOVA(data=between.3, dv="SCORE", between=c("A", "B", "C"))


#### Within-Subjects Design ####

within.1
MANOVA(data=within.1, dvs="A1:A4", dvs.pattern="A(.)",
       within="A")
## the same:
MANOVA(data=within.1, dvs=c("A1", "A2", "A3", "A4"), dvs.pattern="A(.)",
       within="MyFactor")  # renamed the within-subjects factor

within.2
MANOVA(data=within.2, dvs="A1B1:A2B3", dvs.pattern="A(.)B(.)",
       within=c("A", "B"))

within.3
MANOVA(data=within.3, dvs="A1B1C1:A2B2C2", dvs.pattern="A(.)B(.)C(.)",
       within=c("A", "B", "C"))


#### Mixed Design ####

mixed.2_1b1w
MANOVA(data=mixed.2_1b1w, dvs="B1:B3", dvs.pattern="B(.)",
       between="A", within="B")
MANOVA(data=mixed.2_1b1w, dvs="B1:B3", dvs.pattern="B(.)",
       between="A", within="B", sph.correction="GG")

mixed.3_1b2w
MANOVA(data=mixed.3_1b2w, dvs="B1C1:B2C2", dvs.pattern="B(.)C(.)",
       between="A", within=c("B", "C"))

mixed.3_2b1w
MANOVA(data=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=data.new, dvs="Cond_01:Cond_04", dvs.pattern="Cond_(..)",
       between="Group", within="Condition")  # renamed the within-subjects factor

?afex::obk.long
MANOVA(data=afex::obk.long, subID="id", dv="value",
       between=c("treatment", "gender"), within=c("phase", "hour"), cov="age",
       sph.correction="GG")


[Package bruceR version 0.7.0 Index]