Learn R Programming

nauf (version 1.1.0)

nauf_model.matrix: Create a fixed effects model matrix using nauf contrasts.

Description

nauf_model.matrix creates a model matrix which employs nauf_contrasts for unordered factors.

Usage

nauf_model.matrix(object = NULL, data = NULL, ...)

Arguments

object

A nauf.frame or a regression formula. See 'Details'.

data

A nauf.frame or a data.frame containing the variables in object if object is a regression formula. See 'Details'.

...

Further arguments to be passed to nauf_model.frame when object is a regression formula and data is a data.frame. See 'Details'.

Value

A fixed effects model matrix that implements nauf_contrasts. Unlike the default model.matrix method, the model matrix does not have a contrasts attribute, since multiple sets of contrasts may be required for some unordered factors.

Details

Exactly what happens depends on the values of object and data. The following possibilities are evaluated in the order listed:

object is a nauf.frame

All arguments besides object are ignored, and the information in object is used to create the model matrix.

data is a nauf.frame

All arguments besides data are ignored, and the information in data is used to create the model matrix.

object is a formula and data is a data.frame

nauf_model.frame is called with formula = object and data = data, passing along any additional arguments in ... (including ncs_scale). Then the model matrix is created using the information in the resulting nauf.frame.

any other argument values

An error is returned.

See Also

nauf_contrasts for a description of the contrasts applied to unordered factors, nauf_model.frame for creating a model frame with nauf contrasts, and nauf_glFormula for obtaining both fixed effects and random effects model matrices.

Examples

Run this code
dat <- plosives
dat$spont[dat$dialect == "Valladolid"] <- NA
form <- intdiff ~ voicing * dialect * spont +
  (1 + voicing * spont | speaker) + (1 + dialect | item)
sobj <- standardize(form, dat)
mf <- nauf_model.frame(sobj$formula, sobj$data)

## the following all result in the same model matrix
mm1 <- nauf_model.matrix(mf)
mm2 <- nauf_model.matrix(form, mf)  # 'form' ignored
mm3 <- nauf_model.matrix(sobj$formula, sobj$data)

Run the code above in your browser using DataLab