R/logLik.vec2var.R

Defines functions logLik.vec2var

Documented in logLik.vec2var

logLik.vec2var <- function(object, ...){
    obs <- object$obs
    K <- object$K
    resids <- resid(object)
    Sigma <- crossprod(resids) / obs
    r <- -(obs * K/2) * log(2 * pi) - (obs/2) * log(det(Sigma)) - 
        (1/2) * sum(diag(resids %*% solve(Sigma) %*% t(resids)))
    class(r) <- "logLik"
    params <- length(unlist(object$A)) + length(object$deterministic)
    attr(r, "df") <- params
    attr(r, "nobs") <- object$obs
    return(r)
}
cheaton/vars2 documentation built on Oct. 1, 2018, 12:22 a.m.