% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/inference.R
\name{ks_pvalue}
\alias{ks_pvalue}
\title{Two-Sample Kolmogorov-Smirnov-Type Test via Cluster Bootstrap}
\usage{
ks_pvalue(diff_point, diff_boot, scale)
}
\arguments{
\item{diff_point}{Numeric vector. Observed group difference of the
point estimator (\eqn{\hat P_1 - \hat P_0}) on a fixed time grid.}

\item{diff_boot}{Numeric matrix. Cluster bootstrap replicates of the
group difference: rows = time points (matching \code{diff_point}),
columns = replicates.}

\item{scale}{Numeric scalar. Asymptotic scaling factor applied to
both the observed sup-statistic and the bootstrap analogue.
Use \eqn{\sqrt{n}} (\eqn{n} = total clusters) for the
dependent-groups design (Bakoyannis 2021, Theorem 3); use
\eqn{\sqrt{n_1 n_2 / (n_1 + n_2)}} for the cluster-randomized
design (Bakoyannis & Bandyopadhyay 2022, Theorem 2).}
}
\value{
A list with elements \code{statistic} (the observed
  sup-statistic, on the chosen scale) and \code{p.value}.
}
\description{
Computes a p-value for the null hypothesis that a transition
probability curve is equal across two groups, based on the supremum
of the absolute difference between group-specific Aalen-Johansen
estimators and a cluster-bootstrap reference distribution.
}
\details{
The test statistic is \eqn{T = c_n \sup_t | \hat P_1(t) -
\hat P_0(t) |} with \eqn{c_n =} \code{scale}, and the null
distribution is approximated by the bootstrap analogue applied to
centered bootstrap differences. The empirical p-value is invariant
to \code{scale} (it appears on both sides of the comparison); the
role of \code{scale} is to put the reported statistic on the
correct asymptotic scale per the relevant theorem.

This v0.1 implementation uses a unit weight: every time point on
the grid contributes equally to the supremum. Bakoyannis (2021)
Section 2.5 instead recommends a time-varying weight
\eqn{W(t) = \prod_p Y_p(t) / \sum_p Y_p(t)} (the harmonic mean of
the per-group at-risk processes), which downweights regions where
one group's at-risk set is small and naturally tames tail
instability of the difference estimator. A weighted variant
following Bakoyannis (2021) Section 2.5 and Bakoyannis & Bandyopadhyay
(2022) is planned for v0.2.
}
