% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bootstrap_network.R
\name{bootstrap_network}
\alias{bootstrap_network}
\title{Bootstrap a Network Estimate}
\usage{
bootstrap_network(
  x,
  iter = 1000L,
  ci_level = 0.05,
  inference = "stability",
  consistency_range = c(0.75, 1.25),
  edge_threshold = NULL,
  seed = NULL
)
}
\arguments{
\item{x}{A \code{netobject} from \code{\link{build_network}}.
The data, method, params, scaling, threshold, and level are all
extracted from this object.}

\item{iter}{Integer. Number of bootstrap iterations (default: 1000).}

\item{ci_level}{Numeric. Significance level for CIs and p-values
(default: 0.05).}

\item{inference}{Character. \code{"stability"} (default) tests whether
bootstrap replicates fall within a multiplicative consistency range
around the original weight. \code{"threshold"} tests whether
replicates exceed a fixed edge threshold.}

\item{consistency_range}{Numeric vector of length 2. Multiplicative
bounds for stability inference (default: \code{c(0.75, 1.25)}).}

\item{edge_threshold}{Numeric or NULL. Fixed threshold for
\code{inference = "threshold"}. If NULL, defaults to the 10th
percentile of absolute original edge weights.}

\item{seed}{Integer or NULL. RNG seed for reproducibility.}
}
\value{
An object of class \code{"net_bootstrap"} containing:
\describe{
\item{original}{The original \code{netobject}.}
\item{mean}{Bootstrap mean weight matrix.}
\item{sd}{Bootstrap SD matrix.}
\item{p_values}{P-value matrix.}
\item{significant}{Original weights where p < ci_level, else 0.}
\item{ci_lower}{Lower CI bound matrix.}
\item{ci_upper}{Upper CI bound matrix.}
\item{cr_lower}{Consistency range lower bound (stability only).}
\item{cr_upper}{Consistency range upper bound (stability only).}
\item{summary}{Long-format data frame of edge-level statistics.}
\item{model}{Pruned \code{netobject} (non-significant edges zeroed).}
\item{method, params, iter, ci_level, inference}{Bootstrap config.}
\item{consistency_range, edge_threshold}{Inference parameters.}
}
}
\description{
Non-parametric bootstrap for any network estimated by
\code{\link{build_network}}. Works with all built-in methods
(transition and association) as well as custom registered estimators.

For transition methods (\code{"relative"}, \code{"frequency"},
\code{"co_occurrence"}), uses a fast pre-computation strategy:
per-sequence count matrices are computed once, and each bootstrap
iteration only resamples sequences via \code{colSums} (C-level)
plus lightweight post-processing. Data must be in wide format for
transition bootstrap; use \code{\link{convert_sequence_format}} to
convert long-format data first.

For association methods (\code{"cor"}, \code{"pcor"}, \code{"glasso"},
and custom estimators), the full estimator is called on resampled rows
each iteration.
}
\examples{
net <- build_network(data.frame(V1 = c("A","B","C"), V2 = c("B","C","A")),
  method = "relative")
boot <- bootstrap_network(net, iter = 10)
\donttest{
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)
}

}
\seealso{
\code{\link{build_network}}, \code{\link{print.net_bootstrap}},
\code{\link{summary.net_bootstrap}}
}
