maximal.lmer: Linear Mixed Effect Model with Maximal Random Effects...

View source: R/maximal.lmer.R

maximal.lmerR Documentation

Linear Mixed Effect Model with Maximal Random Effects Structure

Description

Determine the call for an lmer model with the maximal random effects structure for a prototypical psycholinguistic design with a factorial experimental design and with subjects and items as (crossed or partially crossed) random effects.

Usage

maximal.lmer(
  data,
  outcome,
  subjects = "Subject",
  items = "Item",
  ivs = NULL,
  within.subjects = NULL,
  within.items = NULL,
  fit.model = FALSE,
  ...
)

Arguments

data

a data frame containing the data to be fit with the model.

outcome

the name of the column containing the outcome variable (i.e., the dependent variable in an experimental study).

subjects

the name of the column containing the subject names or subject numbers.

items

the name of the column containing the item names or item numbers

ivs

the name(s) of the columns containing the independent or predictor variables (excluding the subjects and items).

within.subjects

the names of the IV columns, if any, that are within-subjects variables (i.e., each subject sees more than one level of this variable).

within.items

the names of the IV columns, if any, that are within-item variables (i.e., each subject sees more than one level of this variable).

fit.model

logical - should the model actually be fit, or should the function merely return a string describing the model call?

...

additional arguments to lmer.

Details

This function is only applicable to the set of designs in which there are exactly two sampling units (subjects and items) and all of the variables are factorially crossed. Although such designs are common in psycholinguistics, many other designs are certainly possible and are also valid applications of linear mixed effects models (merely outside the purview of this function).

In addition, the maximal random effects structure may or may not be appropriate for the particular dataset or analytic question (e.g., the model may be overparameterized). This function is provided simply to help beginning users understand how the model call relates to the experimental design and as a shortcut for when a maximal random effects structure is known to be desired.

Value

either a model of class merMod or a string containing an lmer function call that could be used to fit that model.

References

Barr, D.J., Levy, R., Scheepers, C., & Tily, H.J. (2013). Random effects structure for confirmatory hypothesis testing: Keep it maximal. Journal of Memory and Language, 68, 255-278.

See Also

maximal.glmer for generalized linear mixed effects models.

Examples

maximal.lmer(data=my.dataframe, outcome='RT',
             subjects='Subject', items='Items',
             ivs=c('SentenceType', 'PrimeType'),
             within.subjects=c('SentenceType', 'PrimeType'),
             within.items='PrimeType', fit.model=FALSE)

sfraundorf/psycholing documentation built on April 23, 2022, 2:50 a.m.