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
dfree(object, mu = TRUE, sigma = TRUE, ...)
Object of class 'lmvar_no_fit' (hence it can also be of class 'lmvar')
Boolean, specifies whether the degrees of freedom for the model for the expectation values must be included.
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
An integer containing the degrees of freedom for the model in object
.
If mu = TRUE
and sigma = TRUE
, the function returns the rank of the model-matrix
If mu = TRUE
and sigma = FALSE
, the function returns the rank of the model-matrix
If mu = FALSE
and sigma = TRUE
, the function returns the rank of the model-matrix
Both model matrices contain a column corresponding to an intercept term. This column is added by lmvar
.
See also the vignette 'Intro'.
# 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