% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sparsify_moments.R
\name{sparsify_moments}
\alias{sparsify_moments}
\title{Externally sparsified network moments (Algorithm 2)}
\usage{
sparsify_moments(
  G1,
  G2,
  rho_target,
  motifs = list("v_shape", "triangle", "star3")
)
}
\arguments{
\item{G1}{A square symmetric binary adjacency matrix (dense or sparse
\code{Matrix}) used to estimate the sparsification probability.}

\item{G2}{A square symmetric binary adjacency matrix from which moments
are computed after edge removal.}

\item{rho_target}{Numeric in \eqn{(0, 1)}; the target edge density
\eqn{\rho^\dagger}.}

\item{motifs}{A list of motif specifications; see
\code{\link{subsample_moments}} for the format.  Defaults to
\code{list("v_shape", "triangle", "star3")}.}
}
\value{
A named numeric vector of density-normalised network moments, or
  \code{NA} values if the graph after edge removal has zero density.
}
\description{
Uses one adjacency matrix (\code{G1}) to estimate the sparsification
probability and a second independent adjacency matrix (\code{G2}) to
compute density-normalised network moments after random edge removal to a
common target density.  The resulting statistic
\eqn{\bar\Psi_{\rho^\dagger}(G_1, G_2)} is the building block for the
two-sample test in \code{\link{two_sample_test}}.
}
\section{Algorithm}{

\enumerate{
  \item Estimate \eqn{\hat{p} = \min\!\left(1,\,\rho^\dagger /
    \hat\rho_{G_1}\right)}.
  \item Randomly remove edges from \eqn{G_2}: each edge is retained
    independently with probability \eqn{\hat{p}}, yielding
    \eqn{\tilde{G}_2}.
  \item Return \eqn{\hat\rho_{\tilde{G}_2}^{-|E(R)|} \cdot
    U_R(\tilde{G}_2)} for each motif \eqn{R}.
}
}

\examples{
\donttest{
library(randnet)
set.seed(2)
G1 <- BlockModel.Gen(lambda = 15, n = 100, K = 3)$A
G2 <- BlockModel.Gen(lambda = 15, n = 100, K = 3)$A
sparsify_moments(G1, G2, rho_target = 0.08)
}

}
\references{
Qi, Hua, Li and Zhou (2024). Multivariate Inference of Network Moments by
Subsampling. \emph{Biometrika}, \strong{111}(1), 1--18.
\doi{10.1093/biomet/asad056}.
}
