Learn R Programming

lmvar (version 1.5.2)

alias.lmvar_no_fit: Aliased coefficients in an 'lmvar' object

Description

Returns the columns present in the user-specified model-matrices \(X_\mu\) and \(X_\sigma\) that were removed by lmvar to make the matrices full-rank.

Usage

# S3 method for lmvar_no_fit
alias(object, mu = TRUE, sigma = TRUE, ...)

Arguments

object

Object of class 'lmvar_no_fit' (hence it can also be of class 'lmvar')

mu

Boolean, specifies whether the aliased columns from the model matrix \(X_\mu\) must be returned

sigma

Boolean, specifies whether the aliased columns from the model matrix \(X_\sigma\) must be returned

...

Additional arguments, not used in the current implementation

Value

A character vector containing the names of the aliased columns

Details

If mu = TRUE and sigma = TRUE, the function returns the aliased columns of both \(X_\mu\) and \(X_\sigma\). The string "_s" is appended to the aliased column names from \(X_\sigma\) if at least one of those names also appears in \(X_\mu\)

If mu = TRUE and sigma = FALSE, the function returns the aliased columns of \(X_\mu\).

If mu = FALSE and sigma = TRUE, the function returns the aliased columns of \(X_\sigma\).

Examples

Run this code
# NOT RUN {
# Create matrix columns
my_intercept = rep(1, 20)
v1 = c(rep(1, 10), rep(0, 10))
v2 = c(rep(0, 10), rep(1, 10))

# Create model matrices
X = cbind(my_intercept, v1, v2)
X_s = X

# Rename the last column of the model matrix 'X_s' to make this example more clear.
colnames(X_s)[3] = "v3"

# Create response vector
y = rnorm(20)

# Perform fit
fit = lmvar(y, X, X_s)

# The column 'my_intercept' is identical to '(Intercept)' added by 'lmvar'
# to the model matrix 'X'. Column 'v2' is equal to '(Intercept)' minus 'v1'.
# The same holds for the model matrix 'X_s'.
alias(fit)

# The aliased columns are left out if you extract the coefficients from a summary
coef(summary(fit))

# Only return the aliased colums in the model matrix for the expectation values
alias(fit, sigma = FALSE)

# Only return the aliased colums in the model matrix for the standard deviations
alias(fit, mu = FALSE)

# It also works on an object of class 'lmvar_no_fit'
no_fit = lmvar_no_fit(y, X, X_s)
alias(no_fit, mu = FALSE)
# }

Run the code above in your browser using DataLab