Fast, single-call bootstrap for EBICglasso partial correlation networks. Combines nonparametric edge/centrality bootstrap, case-dropping stability analysis, edge/centrality difference tests, predictability CIs, and thresholded network into one function. Designed as a faster alternative to bootnet with richer output.
Usage
boot_glasso(
x,
iter = 1000L,
cs_iter = 500L,
cs_drop = seq(0.1, 0.9, by = 0.1),
alpha = 0.05,
gamma = 0.5,
nlambda = 100L,
centrality = c("strength", "expected_influence", "betweenness", "closeness"),
centrality_fn = NULL,
cor_method = "pearson",
ncores = 1L,
seed = NULL
)
# S3 method for class 'boot_glasso'
print(x, ...)
# S3 method for class 'boot_glasso'
summary(object, type = "edges", ...)
# S3 method for class 'boot_glasso'
plot(x, type = "edges", measure = NULL, ...)Arguments
- x
A data frame, numeric matrix (observations x variables), or a
netobjectwithmethod = "glasso". For theprint()andplot()methods: an object of classboot_glasso.- iter
Integer. Number of nonparametric bootstrap iterations (default: 1000).
- cs_iter
Integer. Total number of case-dropping iterations (default: 500). Following bootnet, each iteration draws one drop proportion at random from
cs_drop, so the iterations are spread across the proportions rather than repeatedcs_itertimes at each one.- cs_drop
Numeric vector. Drop proportions for CS-coefficient computation (default:
seq(0.1, 0.9, by = 0.1)).- alpha
Numeric. Significance level for CIs (default: 0.05).
- gamma
Numeric. EBIC hyperparameter (default: 0.5).
- nlambda
Integer. Number of lambda values in the regularization path (default: 100).
- centrality
Character vector. Centrality measures to compute. All four built-in measures (
"strength","expected_influence","betweenness","closeness") are computed internally with no extra dependencies and are always taken from the built-in path even ifcentrality_fnis supplied. Names that are not one of these four are valid only when acentrality_fnis supplied; that function is then responsible for returning them. Default:c("strength", "expected_influence", "betweenness", "closeness").- centrality_fn
Optional function. A custom centrality function that takes a weight matrix and returns a named list of centrality vectors. When
NULL(default), all four built-in measures are computed internally:"strength"/"expected_influence"viarowSums, and"betweenness"/"closeness"via an internal Floyd-Warshall shortest-path routine. When provided, the function is called ascentrality_fn(mat)and is used only for requested measures that are not one of the four built-ins; it should return a named list (e.g.,list(my_metric = ...)).- cor_method
Character. Correlation method:
"pearson"(default),"spearman", or"kendall".- ncores
Integer. Number of parallel cores for mclapply (default: 1, sequential).
- seed
Integer or NULL. RNG seed for reproducibility.
- ...
In
plot.boot_glasso(): Additional arguments passed to plotting functions. Fortype = "edge_diff"andtype = "centrality_diff", acceptsorder:"sample"(default, sorted by value) or"id"(alphabetical). Inprint.boot_glasso()andsummary.boot_glasso(): Additional arguments (ignored).- object
For the
summary()method: an object of classboot_glasso.- type
In
summary.boot_glasso(): Character. Summary type:"edges"(default),"centrality","cs","predictability", or"all". Inplot.boot_glasso(): Character. Plot type:"edges"(default),"stability","edge_diff","centrality_diff", or"inclusion".- measure
Character. Centrality measure for
type = "centrality_diff"(default: first available measure).
Value
An object of class "boot_glasso" containing:
- original_pcor
Original partial correlation matrix.
- original_precision
Original precision matrix.
- original_centrality
Named list of original centrality vectors.
- original_predictability
Named numeric vector of node R-squared.
- edge_ci
Data frame of edge CIs (edge, weight, ci_lower, ci_upper, inclusion).
- edge_inclusion
Named numeric vector of edge inclusion probabilities.
- thresholded_pcor
Partial correlation matrix with non-significant edges zeroed.
- centrality_ci
Named list of data frames (node, value, ci_lower, ci_upper) per centrality measure.
- cs_coefficient
Named numeric vector of CS-coefficients per centrality measure.
- cs_data
Data frame of case-dropping results, one row per drop proportion by measure, with columns
drop_prop,measure,mean_cor,prop_above(fraction of that proportion's iterations correlating above 0.7) andn_samples(iterations that landed on that proportion).- edge_diff_p
Symmetric matrix of pairwise edge difference p-values;
NULLwhen the network has more than 500 edges.- centrality_diff_p
Named list of symmetric p-value matrices per centrality measure.
- predictability_ci
Data frame of node predictability CIs (node, r2, ci_lower, ci_upper).
- boot_edges
iter x n_edges matrix of bootstrap edge weights.
- boot_centrality
Named list of iter x p bootstrap centrality matrices.
- boot_predictability
iter x p matrix of bootstrap R-squared.
- nodes
Character vector of node names.
- n
Sample size.
- p
Number of variables.
- iter
Number of nonparametric iterations.
- cs_iter
Number of case-dropping iterations.
- cs_drop
Drop proportions used.
- alpha
Significance level.
- gamma
EBIC hyperparameter.
- nlambda
Lambda path length.
- centrality_measures
Character vector of centrality measures.
- cor_method
Correlation method.
- lambda_path
Lambda sequence used.
- lambda_selected
Selected lambda for original data.
- timing
Named numeric vector with timing in seconds.
In print.boot_glasso(): The input object, invisibly.
In summary.boot_glasso(): For type = "edges", the edge_ci data frame (edge, weight, ci_lower, ci_upper, inclusion) ordered by decreasing absolute weight; for "cs" the cs_data data frame; for "predictability" the predictability_ci data frame; for "centrality" a named list of one data frame per measure (node, value, ci_lower, ci_upper); for "all" a named list holding all four.
In plot.boot_glasso(): A ggplot object (returned, and so printed when the call is made at the top level).
References
Epskamp, S., Borsboom, D., & Fried, E. I. (2018). Estimating psychological networks and their accuracy: A tutorial paper. Behavior Research Methods 50(1), 195-212. doi:10.3758/s13428-017-0862-1 (source of the CS-coefficient and of the case-dropping, edge-difference and centrality-difference procedures reproduced here.)
Examples
set.seed(1)
dat <- as.data.frame(matrix(rnorm(60), ncol = 3))
net <- build_network(dat, method = "glasso")
bg <- boot_glasso(net, iter = 10, cs_iter = 5, centrality = "strength")
# \donttest{
set.seed(42)
mat <- matrix(rnorm(60), ncol = 4)
colnames(mat) <- LETTERS[1:4]
net <- build_network(as.data.frame(mat), method = "glasso")
# iter = 20 keeps the example fast; a real analysis uses 1000 or more.
boot <- boot_glasso(net, iter = 20, cs_iter = 10, seed = 42,
centrality = c("strength", "expected_influence"))
print(boot)
#> GLASSO Bootstrap (20 iterations, 10 case-drop per proportion)
#> Data: 15 x 4 | Alpha: 0.05 | Gamma: 0.50
#> Edges: 0/6 significant (CI excludes zero)
#> Mean inclusion probability: 0.34
#>
#> Centrality Stability (CS-coefficient):
#> strength: 0.00 [Unstable]
#> expected_influence: 0.00 [Unstable]
#>
#> Edge differences: 1/15 pairs significantly different
#> Timing: 1.3s (bootstrap: 0.8s, case-drop: 0.4s)
summary(boot, type = "edges")
#> edge weight ci_lower ci_upper inclusion
#> 1 A -- B 0 -0.11158199 0.2237170 0.35
#> 2 A -- C 0 -0.35185599 0.0000000 0.45
#> 3 B -- C 0 -0.30946821 0.2065199 0.25
#> 4 A -- D 0 0.00000000 0.3570903 0.50
#> 5 B -- D 0 -0.15048304 0.3105727 0.35
#> 6 C -- D 0 -0.03724162 0.1787669 0.15
# }