# NOT RUN {
library("cglasso")
#################
# cglasso model #
#################
set.seed(123)
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)
coef(out, nrho = 3L, type = "theta", print.info = TRUE)
Tht_hat <- coef(out, nrho = 3L, type = "theta")
Tht_hat
coef(out, nrho = 3L, type = "sigma", print.info = TRUE)
Sgm_hat <- coef(out, nrho = 3L, type = "sigma")
Sgm_hat
coef(out, nrho = 3L, type = "mu", print.info = TRUE)
mu_hat <- coef(out, nrho = 3L, type = "mu")
mu_hat
#################
# mglasso model #
#################
R <- event(X)
X <- as.matrix(X)
X[R == 1L] <- NA
out <- mglasso(X = X)
coef(out, nrho = 3L, type = "theta", print.info = TRUE)
Tht_hat <- coef(out, nrho = 3L, type = "theta")
Tht_hat
coef(out, nrho = 3L, type = "sigma", print.info = TRUE)
Sgm_hat <- coef(out, nrho = 3L, type = "sigma")
Sgm_hat
coef(out, nrho = 3L, type = "mu", print.info = TRUE)
mu_hat <- coef(out, nrho = 3L, type = "mu")
mu_hat
################
# glasso model #
################
X <- MASS::mvrnorm(n = n, mu = mu, Sigma = Sgm)
out <- glasso(X = X)
coef(out, nrho = 3L, type = "theta", print.info = TRUE)
Tht_hat <- coef(out, nrho = 3L, type = "theta")
Tht_hat
coef(out, nrho = 3L, type = "sigma", print.info = TRUE)
Sgm_hat <- coef(out, nrho = 3L, type = "sigma")
Sgm_hat
# }
Run the code above in your browser using DataLab