Learn R Programming

lmvar (version 1.5.2)

coef.lmvar: Extracts coefficients from an 'lmvar' object.

Description

Extracts maximum-likelihood estimators for \(\beta_\mu\) and \(\beta_\sigma\) from an 'lmvar' object.

Usage

# S3 method for lmvar
coef(object, mu = TRUE, sigma = TRUE, ...)

Arguments

object

Object of class 'lmvar'

mu

Boolean, specifies whether or not to return the maximum-likelihood estimator for \(\beta_\mu\)

sigma

Boolean, specifies whether or not to return the maximum-likelihood estimator for \(\beta_\sigma\)

...

For compatibility with coef generic

Value

When mu = TRUE and sigma = TRUE, a named numeric vector with the elements of \(\beta_\mu\), followed by the elements of \(\beta_\sigma\).

When mu = TRUE and sigma = FALSE, a named numeric vector with the elements of \(\beta_\mu\).

When mu = FALSE and sigma = TRUE, a named numeric vector with the elements of \(\beta_\sigma\).

Details

When both mu = TRUE and sigma = TRUE, the names of the coefficients in \(\beta_\sigma\) are adapted to distinguish them from the names in \(\beta_\mu\), if needed.

See Also

beta_sigma_names for the adaptation of the names of the coefficients in \(\beta_\sigma\).

confint for the calculation of confidence intervals of \(\beta_\mu\) and \(\beta_\sigma\).

Examples

Run this code
# NOT RUN {
# As example we use the dataset 'attenu' from the library 'datasets'. The dataset contains
# the response variable 'accel' and two explanatory variables 'mag'  and 'dist'.
library(datasets)

# Create the model matrix for the expected values
X = cbind(attenu$mag, attenu$dist, attenu$mag + attenu$dist)
colnames(X) = c("mag", "dist", "mag+dist")

# Create the model matrix for the standard deviations.
X_s = cbind(attenu$mag, 1 / attenu$dist)
colnames(X_s) = c("mag", "dist_inv")

# Carry out the fit
fit = lmvar(attenu$accel, X, X_s)

# Extract all coefficients
coef(fit)

# Extract only the coefficients corresponding to the (non-aliased)
# columns in the model matrix for the expected values
coef(fit, sigma = FALSE)

# Extract only the coefficients corresponding to the (non-aliased)
# columns in the model matrix for standard deviations
coef(fit, mu = FALSE)
# }

Run the code above in your browser using DataLab