to_graph {cglasso}R Documentation

Create Graphs from cglasso or cggm Objects

Description

to_graph’ returns a named list of graphs using the results of an R object of class ‘cglasso’ or ‘cggm’.

Usage

to_graph(object, GoF = AIC, lambda.id, rho.id, weighted = FALSE, simplify = TRUE,
         ...)

Arguments

object

an R object inheriting class ‘cglasso’, that is, the output of the model-fitting functions cglasso and cggm.

GoF

a valid goodness-of-fit function, such as AIC.cglasso or BIC.cglasso, or an R object of class ‘GoF’.

lambda.id

optional. If object has class ‘cglasso’, this argument is an integer used to identify a specific fitted cglasso model, otherwise (i.e. if the object has class ‘cggm’) this argument can be omitted. See section ‘Details’ for more details.

rho.id

optional. If object has class ‘cglasso’, this argument is an integer used to identify a specific fitted cglasso model, otherwise (i.e. if object has class ‘cggm’) this argument can be omitted. See section ‘Details’ for more details.

weighted

logical. Should weighted graphs be created? Default is FALSE.

simplify

logical. Should isolated vertices be removed from the graph? Default is TRUE, i.e., isolated vertices are removed.

...

further arguments passed to the chosen goodness-of-fit function (argument ‘GoF’).

Details

to_graph’ returns a named list of graphs using the results of an R object of class ‘cglasso’ or ‘cggm’.

If object has class ‘cglasso’, then the goodness-of-fit function passed through the argument GoF is used to identify the adjacency matrix (object$InfoStructure$Adj_yy) describing the undirected edges among the p response variables. If the model is fitted using q predictors, then the matrix describing the effects of the predictors onto the response variables (see object$InfoStructure$Adj_xy) is also returned. Finally, these matrices are used to return an undirected and directed graph. Opionally, the user can identify a specific fitted model using the arguments lambda.id and rho.id.

If object has class ‘cggm’, then GoF, lambda.id and rho.id can be omitted.

If argument weighted is set equal to ‘TRUE’, then the estimated precision matrix and, if available, the estimated regression coefficient matrix are used to return weighted graphs. In this case, edges associated with positive estimates are shown using a solid line. Otherwise, a dashed line is used.

Value

to_graph’ returns an R object of S3 class “cglasso2igraph”, i.e., a named list containing the following components:

Gyy

an undirected graph representing the conditional dependence structure among the p response variables.

Gxy

a directed graph representing the effetcs of the q predictors onto the p response variables.

Each component is an R object of class igraph.

Author(s)

Luigi Augugliaro (luigi.augugliaro@unipa.it)

See Also

cglasso, cggm and plot.cglasso2igraph. For more details about the object of class ‘igraph’, the interested reader is referred to the package igraph.

Examples

set.seed(123)
# Y ~ N(0, Sigma) and probability of left/right censored values equal to 0.05
n <- 100L
p <- 3L
rho <- 0.3
Sigma <- outer(1L:p, 1L:p, function(i, j) rho^abs(i - j))
Z <- rcggm(n = n, Sigma = Sigma, probl = 0.05, probr = 0.05)
out <- cglasso(. ~ ., data = Z)
out.graph <- to_graph(out)
out.graph

# Y ~ N(b0 + XB, Sigma)  and probability of left/right censored values equal to 0.05
n <- 100L
p <- 3L
q <- 2L
b0 <- runif(p)
B <- matrix(runif(q * p), nrow = q, ncol = p)
X <- matrix(rnorm(n * q), nrow = n, ncol = q)
rho <- 0.3
Sigma <- outer(1L:p, 1L:p, function(i, j) rho^abs(i - j))
Z <- rcggm(n = n, b0 = b0, X = X, B = B, Sigma = Sigma, probl = 0.05, probr = 0.05)
out <- cglasso(. ~ ., data = Z)
out.graph <- to_graph(out, lambda.id = 3, rho.id = 3, weighted = TRUE)
out.graph

[Package cglasso version 2.0.7 Index]