Learn R Programming

semEff (version 0.1.0)

xNam: Get Model Term Names

Description

Extract term names from a fitted model object.

Usage

xNam(mod, intercept = TRUE, aliased = TRUE, list = FALSE, ...)

Arguments

mod

A fitted model object of class "lm", "glm", or "merMod", or a list or nested list of such objects.

intercept

Logical, whether the intercept term should be included.

aliased

Logical, whether names of aliased terms should be included (see Details).

list

Logical, whether names should be returned as a list, with all multi-coefficient terms grouped under their term names.

...

Not currently used.

Value

A character vector or list/nested list of term names.

Details

Extract term names from a fitted model. Names of terms for which coefficients cannot be estimated are also included if aliased = TRUE (default). These may be terms which are perfectly correlated with other terms in the model, so that the model design matrix is rank deficient.

Examples

Run this code
# NOT RUN {
## Term names from Shipley SEM
m <- Shipley.SEM
xNam(m)
xNam(m, intercept = FALSE)  # only predictors

## Model with different types of predictor (some multi-coefficient terms)
x1 <- poly(rnorm(100), 2)  # polynomial
x2 <- as.factor(rep(c("a", "b", "c", "d"), each = 25))  # categorical
x3 <- rep(1, 100)  # no variation
m <- lm(rnorm(100) ~ x1 + x2 + x3)
xNam(m)
xNam(m, aliased = FALSE)  # drop term that cannot be estimated (x3)
xNam(m, aliased = FALSE, list = TRUE)  # as named list
# }

Run the code above in your browser using DataLab