View source: R/bootstrap_network.R
| bootstrap_network | R Documentation |
Non-parametric bootstrap for any network estimated by
build_network. Works with all built-in methods
(transition and association) as well as custom registered estimators.
For transition methods ("relative", "frequency",
"co_occurrence"), uses a fast pre-computation strategy:
per-sequence count matrices are computed once, and each bootstrap
iteration only resamples sequences via colSums (C-level)
plus lightweight post-processing. Data must be in wide format for
transition bootstrap; use convert_sequence_format to
convert long-format data first.
For association methods ("cor", "pcor", "glasso",
and custom estimators), the full estimator is called on resampled rows
each iteration.
bootstrap_network(
x,
iter = 1000L,
ci_level = 0.05,
inference = "stability",
consistency_range = c(0.75, 1.25),
edge_threshold = NULL,
seed = NULL
)
x |
A |
iter |
Integer. Number of bootstrap iterations (default: 1000). |
ci_level |
Numeric. Significance level for CIs and p-values (default: 0.05). |
inference |
Character. |
consistency_range |
Numeric vector of length 2. Multiplicative
bounds for stability inference (default: |
edge_threshold |
Numeric or NULL. Fixed threshold for
|
seed |
Integer or NULL. RNG seed for reproducibility. |
An object of class "net_bootstrap" containing:
The original netobject.
Bootstrap mean weight matrix.
Bootstrap SD matrix.
P-value matrix.
Original weights where p < ci_level, else 0.
Lower CI bound matrix.
Upper CI bound matrix.
Consistency range lower bound (stability only).
Consistency range upper bound (stability only).
Long-format data frame of edge-level statistics.
Pruned netobject (non-significant edges zeroed).
Bootstrap config.
Inference parameters.
build_network, print.net_bootstrap,
summary.net_bootstrap
net <- build_network(data.frame(V1 = c("A","B","C"), V2 = c("B","C","A")),
method = "relative")
boot <- bootstrap_network(net, iter = 10)
seqs <- data.frame(
V1 = sample(LETTERS[1:4], 30, TRUE), V2 = sample(LETTERS[1:4], 30, TRUE),
V3 = sample(LETTERS[1:4], 30, TRUE), V4 = sample(LETTERS[1:4], 30, TRUE)
)
net <- build_network(seqs, method = "relative")
boot <- bootstrap_network(net, iter = 100)
print(boot)
summary(boot)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.