coef {cglasso} | R Documentation |
‘coef
’ extracts model coefficients from a fitted model.
## S3 method for class 'glasso' coef(object, ..., nrho = 1L, type = c("theta", "sigma"), print.info = FALSE, digits = 3L) ## S3 method for class 'mglasso' coef(object, ..., nrho = 1L, type = c("theta", "sigma", "mu"), print.info = FALSE, digits = 3L)
object |
an object with class ‘ |
nrho |
integer used to specify the model from which to extract the coefficients. Default is |
type |
a string specifying the returned parameters. If ‘ |
print.info |
flag specifying if information about the model is printed out. Default is |
digits |
the minimum number of significant digits to be used. Default is |
... |
additional argument added for backward compatibility with the generic function coef. |
By default, the method functions ‘coef.glasso
’ and ‘coef.mglasso
’ return the parameters specified by the argument ‘type
’.
If ‘print.info = TRUE
’ then the estimated parameters are silently returned and information about the chosen model is printed out, i.e. the value of the tuning parameter, the value of the pseudo R-squared, the number of connected components and the number of vertices per connected component. Furthermore, to improve the readability of the results the estimates are printed out taken into account the connected components (see the examples below).
Coefficients extracted from ‘object
’ are returned.
Luigi Augugliaro (luigi.augugliaro@unipa.it)
glasso
, mglasso
, cglasso
and mle
.
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