plot {cglasso} | R Documentation |
glasso
’ and ‘cglasso
’ ObjectThe method functions ‘plot.glasso
’ and ‘plot.mglasso
’ produce plots to study the sequence of models estimated by glasso
, mglasso
or cglasso
.
## S3 method for class 'glasso' plot(x, typeplot = c("path", "graph"), gof, diag = FALSE, nrho, weighted = FALSE, isolated = FALSE, ...) ## S3 method for class 'mglasso' plot(x, typeplot = c("path", "graph"), gof, diag = FALSE, nrho, weighted = FALSE, isolated = FALSE, ...)
x |
a fitted model object. |
typeplot |
a string specifying the produced plot. |
gof |
an object with class ‘ |
diag |
flag specifying whether the diagonal elements of the concentration matrix are plotted. |
nrho |
availables only if ‘ |
weighted |
argument availables only if ‘ |
isolated |
flag specifying whether the isolated vertices are removed from the graph. Default is |
... |
additional arguments passed to the method function ‘ |
The plot produced by the method functions ‘plot.glasso
’ and ‘plot.mglasso
’ depends on the argument ‘typeplot
’.
If ‘typeplot = path
’, the regularization paths are produced; in this case, if an object with class ‘gof
’ is passed by the argument ‘gof
’, then a vertical dashed line is added to identify the optimal rho-value.
If ‘typeplot = graph
’, the method functions ‘plot.glasso
’ and ‘plot.mglasso
’ produce the undirected graph associated to the model specified by the argument ‘nrho
’. If an object with class ‘gof
’ is passed by ‘gof
’, the undirected graph of the model selected by the function ‘aic’, ‘bic’ or ‘ebic’ is produced.
If typeplot = "graph"
then the igraph object is returned (see example below).
Luigi Augugliaro (luigi.augugliaro@unipa.it)
library("cglasso") set.seed(123) ################# # cglasso model # ################# n <- 100L p <- 5L mu <- rep.int(0L, times = p) X <- rdatacggm(n = n, mu = mu, probr = 0.05) out <- cglasso(X = X, nrho = 100L) out_aic <- aic(out) # plotting the regularization paths + 'gof' object plot(out, typeplot = "path") plot(out, typeplot = "path", gof = out_aic) # plotting the graph associated to the fitted model # specified by 'nrho' out_graph <- plot(out, typeplot = "graph", nrho = 10L) out_graph # plotting the graph associated to the fitted model # specified by 'gof' out_graph <- plot(out, typeplot = "graph", gof = out_aic) out_graph ################# # mglasso model # ################# R <- event(X) X <- as.matrix(X) X[R == 1L] <- NA out <- mglasso(X = X, nrho = 100L) out_aic <- aic(out) # plotting the regularization paths + 'gof' object plot(out, typeplot = "path") plot(out, typeplot = "path", gof = out_aic) # plotting the graph associated to the fitted model # specified by 'nrho' out_graph <- plot(out, typeplot = "graph", nrho = 10L) out_graph # plotting the graph associated to the fitted model # specified by 'gof' out_graph <- plot(out, typeplot = "graph", gof = out_aic) out_graph ################# # glasso model # ################# X <- MASS::mvrnorm(n = n, mu = mu, Sigma = diag(p)) out <- glasso(X, nrho = 100L) out_aic <- aic(out) # plotting the regularization paths + 'gof' object plot(out, typeplot = "path") plot(out, typeplot = "path", gof = out_aic) # plotting the graph associated to the fitted model # specified by 'nrho' out_graph <- plot(out, typeplot = "graph", nrho = 10L) out_graph # plotting the graph associated to the fitted model # specified by 'gof' out_graph <- plot(out, typeplot = "graph", gof = out_aic) out_graph