ems: Expected values of mean squares for factorial designs...

View source: R/ems.R

emsR Documentation

Expected values of mean squares for factorial designs Implements the Cornfield-Tukey algorithm for deriving the expected values of the mean squares for factorial designs.

Description

Expected values of mean squares for factorial designs

Implements the Cornfield-Tukey algorithm for deriving the expected values of the mean squares for factorial designs.

Usage

ems(design, nested = NULL, random = "")

Arguments

design

A formula object specifying the factors in the design (except residual error, which is always implicitly included). The left hand side of the ~ is the symbol that will be used to denote the number of replications per lowest-level factor combination (I usually use "r" or "n"). The right hand side should include all fixed and random factors separated by *. Factor names should be single letters.

nested

A character vector, where each element is of the form "A/B", indicating that the levels of factor B are nested under the levels of factor A.

random

A character string indicating, without spaces or any separating characters, which of the factors specified in the design are random.

Value

The returned value is a formatted table where the rows represent the mean squares, the columns represent the variance components that comprise the various mean squares, and the entries in each cell represent the terms that are multiplied and summed to form the expectation of the mean square for that row. Each term is either the lower-case version of one of the experimental factors, which indicates the number of levels for that factor, or a "1", which means the variance component for that column is contributes to the mean square but is not multiplied by anything else.

Note

Names for factors or parameters should only be of length 1 as they are simply concatenated in the returned table.

Author(s)

Jake Westfall

See Also

A detailed description with explanation of the example can be found elsewhere (note that the design argument of the function described at the link behaves slightly different).

Example applications of this function can be found here: https://stats.stackexchange.com/a/122662/442.

Examples

# 2x2 mixed anova
# A varies between-subjects, B varies within-subjects
ems(r ~ A*B*S, nested="A/S", random="S")

# Clark (1973) example
# random Subjects, random Words, fixed Treatments
ems(r ~ S*W*T, nested="T/W", random="SW")

# EMSs for Clark design if Words are fixed
ems(r ~ S*W*T, nested="T/W", random="S")


afex documentation built on Sept. 11, 2024, 7:59 p.m.