R/loglik.R

Defines functions loglik

Documented in loglik

loglik <- function(object, N = 2){
	if (N <= 0)
      stop("N must be a positive integer")
	if (N != ceiling(N))
      stop("N must be an integer value")
	p <- dim(object$S)[1L]
	rho <- object$rho
	nv <- object$nv
	ne <- object$ne
	w <- object$w
	th_e <- object$theta[(nv + 1):(nv + ne), , drop = FALSE]
	l1_th_e <- apply(th_e, 2,
                     function(x) {
                        id <- which(abs(x) > 0)
                        sum(w[id] * abs(x[id]))
                     })
	out <- Kh(object)
    out <- unlist(lapply(out, function(x) determinant(x, logarithm = TRUE)$modulus[1L]))
	k <- 0.5 * N
	out <- k * (out - p + rho * l1_th_e)
	out
}

Try the sglasso package in your browser

Any scripts or data that you put into this service are public.

sglasso documentation built on Sept. 22, 2022, 5:06 p.m.