Last chance! 50% off unlimited learning
Sale ends in
‘loglik
’ function extracts the values of the log-liklihood function from an object with class ‘glasso
’ or ‘ggm
’, otherwise the values of the Q-function are returned.
loglik(object)
a fitted model object.
‘loglik
’ returns an object with S3 class “loglik
”, i.e. a list containing the following components:
the values of the log-likelihood or Q-function.
the number of the estimated non-zero parameters, i.e. the number of non-zero partial correlations plus
the sample size.
the number of variables.
the values of the tuning parameter used to fit the model.
the name of the fitted model.
the name of the used function, i.e. the log-likelihood or the Q-function.
If ‘object
’ has class ‘glasso
’ or ‘ggm
’, the function ‘loglik()
’ returns the value of the log-likelihood function:
For the other models, ‘loglik()
’ returns the value of the Q-function, i.e. the function maximaxed in the M-step of the EM-like algorithm. The Q-function is defined as follows:
The method function ‘print.loglik
’ is used the improve the readability of the results.
cglasso
, mglasso
, glasso
, mle
and the method functions, plot
, aic
, bic
and ebic
.
# NOT RUN {
library("cglasso")
set.seed(123)
#################
# cglasso model #
#################
p <- 5L
n <- 100L
mu <- rep(0L, p)
Tht <- diag(p)
diag(Tht[-1L, -p]) <- diag(Tht[-p, -1L]) <- 0.3
Sgm <- solve(Tht)
X <- rdatacggm(n = n, mu = mu, Sigma = Sgm, probr = 0.05)
out <- cglasso(X = X)
out_loglik <- loglik(out)
out_loglik
##############
# cggm model #
##############
out_mle <- mle(out)
out_loglik <- loglik(out_mle)
out_loglik
#################
# mglasso model #
#################
library(MASS)
X <- mvrnorm(n = n, mu = mu, Sigma = Sgm)
id.na <- sample.int(n = n * p, size = n * p * 0.05)
X[id.na] <- NA
out <- mglasso(X = X)
out_loglik <- loglik(out)
out_loglik
##############
# mggm model #
##############
out_mle <- mle(out)
out_loglik <- loglik(out_mle)
out_loglik
################
# glasso model #
#################
X <- mvrnorm(n = n, mu = mu, Sigma = Sgm)
out <- glasso(X)
out_loglik <- loglik(out)
out_loglik
#############
# ggm model #
#############
out_mle <- mle(out)
out_loglik <- loglik(out_mle)
out_loglik
# }
Run the code above in your browser using DataLab