loglik {cglasso} | R Documentation |
‘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)
object |
a fitted model object. |
If ‘object
’ has class ‘glasso
’ or ‘ggm
’, the function ‘loglik()
’ returns the value of the log-likelihood function:
n/2 {log det Tht - tr(S Tht) - p log(2 pi)},
where Tht is estimated using the function glasso or mle.glasso.
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:
n/2 {log det Tht - tr(S' Tht) - p log(2 pi)},
where S' is computed in the E-step.
The method function ‘print.loglik
’ is used the improve the readability of the results.
‘loglik
’ returns an object with S3 class “loglik
”, i.e. a list containing the following components:
value |
the values of the log-likelihood or Q-function. |
df |
the number of the estimated non-zero parameters, i.e. the number of non-zero partial correlations plus 2p. |
n |
the sample size. |
p |
the number of variables. |
rho |
the values of the tuning parameter used to fit the model. |
model |
the name of the fitted model. |
fun |
the name of the used function, i.e. the log-likelihood or the Q-function. |
Luigi Augugliaro (luigi.augugliaro@unipa.it)
cglasso
, mglasso
, glasso
, mle
and the method functions, plot
, aic
, bic
and ebic
.
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