% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/disparity.R
\name{disparity_filter}
\alias{disparity_filter}
\alias{disparity_filter.default}
\alias{disparity_filter.matrix}
\alias{disparity_filter.tna}
\alias{disparity_filter.cograph_network}
\alias{disparity_filter.igraph}
\title{Disparity Filter}
\usage{
disparity_filter(x, level = 0.05, ...)

\method{disparity_filter}{default}(x, level = 0.05, ...)

\method{disparity_filter}{matrix}(x, level = 0.05, ...)

\method{disparity_filter}{tna}(x, level = 0.05, ...)

\method{disparity_filter}{cograph_network}(x, level = 0.05, ...)

\method{disparity_filter}{igraph}(x, level = 0.05, ...)
}
\arguments{
\item{x}{A weight matrix, tna object, cograph_network, or igraph object.}

\item{level}{Significance level (default 0.05). Lower values result in
a sparser backbone (fewer edges retained).}

\item{...}{Additional arguments (currently unused).}
}
\value{
For matrices: a binary matrix (0/1) indicating significant edges.
For tna, cograph_network, and igraph objects: a \code{tna_disparity} object
containing the significance matrix, original weights, filtered weights,
and summary statistics.
}
\description{
Extracts the statistically significant backbone of a weighted network
using the disparity filter method (Serrano, Boguna, & Vespignani, 2009).
}
\details{
The disparity filter identifies edges that carry a disproportionate
fraction of a node's total weight, based on a null model where weights
are distributed uniformly at random.

For each node \eqn{i} with degree \eqn{k_i}, and each edge \eqn{(i,j)}
with normalized weight \eqn{p_{ij} = w_{ij} / s_i} (where \eqn{s_i} is
the node's strength), the p-value is:

\deqn{p = (1 - p_{ij})^{(k_i - 1)}}

Edges are significant if \eqn{p < level} for either endpoint.
}
\examples{
# Create a weighted network
mat <- matrix(c(
  0.0, 0.5, 0.1, 0.0,
  0.3, 0.0, 0.4, 0.1,
  0.1, 0.2, 0.0, 0.5,
  0.0, 0.1, 0.3, 0.0
), nrow = 4, byrow = TRUE)
rownames(mat) <- colnames(mat) <- c("A", "B", "C", "D")

# Extract backbone at 5\% significance level
backbone <- disparity_filter(mat, level = 0.05)
backbone

# More stringent filter (1\% level)
backbone_strict <- disparity_filter(mat, level = 0.01)
}
\references{
Serrano, M. A., Boguna, M., & Vespignani, A. (2009).
Extracting the multiscale backbone of complex weighted networks.
Proceedings of the National Academy of Sciences, 106(16), 6483-6488.
}
\seealso{
\code{\link[tna]{bootstrap}} for bootstrap-based significance testing
}
