Learn R Programming

lmvar (version 1.5.2)

dfree: Degrees of freedom for an object of class 'lmvar'

Description

Degrees of freedom for the model in an object of class 'lmvar'. The degrees of freedom are defined as the rank of the model matrix \(X_\mu\) for the expectation values, plus the rank of the model matrix \(X_\sigma\) for the standard deviations.

Usage

dfree(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 degrees of freedom for the model for the expectation values must be included.

sigma

Boolean, specifies whether the degrees of freedom for the model for the standard deviations must be included.

...

Additional arguments, not used in the current implementation

Value

An integer containing the degrees of freedom for the model in object.

Details

If mu = TRUE and sigma = TRUE, the function returns the rank of the model-matrix \(X_\mu\) plus the rank of the model matrix \(X_\sigma\).

If mu = TRUE and sigma = FALSE, the function returns the rank of the model-matrix \(X_\mu\).

If mu = FALSE and sigma = TRUE, the function returns the rank of the model-matrix \(X_\sigma\).

Both model matrices contain a column corresponding to an intercept term. This column is added by lmvar. See also the vignette 'Intro'.

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)
colnames(X) = c("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)

# The degrees of freedom are
dfree(fit)

# The degrees of freedom of the expected values are
dfree(fit, sigma = FALSE)

# The degrees of freedom of the standard deviations are
dfree(fit, mu = FALSE)

# Function also works on object of class 'lmvar_no_fit'
no_fit = lmvar_no_fit(attenu$accel, X, X_s)
dfree(no_fit)
# }

Run the code above in your browser using DataLab