fixModelMatrix: Fix the "factor" matrix of a terms object.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/ffmanova_div.R

Description

The function takes the factor matrix of the terms object corresponding to a model formula and changes it so that model hierarchy is preserved also for powers of terms (e.g., I(a^2)).

Usage

1

Arguments

mOld

The factor matrix (i.e. the "factor" attribute) of a terms object.

Details

The ordinary model handling functions in do not treat powers of terms (a^n) as being higher order terms (like interaction terms). fixModelMatrix takes the "factor" attribute of a terms object (usually created from a model formula) and changes it such that power terms can be treated hierarchically just like interaction terms.

The factor matrix has one row for each variable and one coloumn for each term. Originally, an entry is 0 if the term does not contain the variable. If it contains the variable, the entry is 1 if the variable should be coded with contrasts, and 2 if it should be coded with dummy variables. See terms.object for details.

The changes performed by fixModelMatrix are:

Note that this changes the semantics of the factor matrix: 2 no longer means ‘code via dummy variables’.

Value

A factor matrix.

Author(s)

<c3><98>yvind Langsrud and Bj<c3><b8>rn-Helge Mevik

See Also

terms, terms.object

Examples

1
2
3
mt <- terms(y ~ a + b + a:b + a:c + I(a^2) + I(a^3) + I(a^2):b)
print(mOld <- attr(mt, "factor"))
fixModelMatrix(mOld)

ffmanova documentation built on May 2, 2019, 2:46 a.m.