Learn R Programming

lmvar (version 1.5.2)

logLik.lmvar: Log-likelihood for an object of class 'lmvar'

Description

Log-likelihood for an object of class 'lmvar'

Usage

# S3 method for lmvar
logLik(object, ...)

Arguments

object

Object of class 'lmvar'

...

For compatibility with logLik generic

Value

'logLik' object, a number containing the log-likelihood with an attribute 'df' containing the degrees of freedom

See Also

dfree for the degrees of freedom for an object of class 'lmvar'.

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)

# Show the log-likelihood and the degrees of freedom of the fit
# using the 'print' method for an object of class 'logLik'
logLik(fit)

# Obtain the log-likelihood itself
logLik(fit)[1]
# }

Run the code above in your browser using DataLab