% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/compare_seroincidence.R
\name{compare_seroincidence}
\alias{compare_seroincidence}
\alias{compare_seroincidence.seroincidence}
\alias{compare_seroincidence.seroincidence.by}
\title{Compare seroincidence rates between two groups}
\usage{
compare_seroincidence(x, y = NULL, coverage = 0.95, verbose = FALSE, ...)

\method{compare_seroincidence}{seroincidence}(x, y = NULL, coverage = 0.95, verbose = FALSE, ...)

\method{compare_seroincidence}{seroincidence.by}(x, y = NULL, coverage = 0.95, verbose = FALSE, ...)
}
\arguments{
\item{x}{A \code{"seroincidence"} object from \code{\link[=est_seroincidence]{est_seroincidence()}} or
a \code{"seroincidence.by"} object from \code{\link[=est_seroincidence_by]{est_seroincidence_by()}}}

\item{y}{A \code{"seroincidence"} object from \code{\link[=est_seroincidence]{est_seroincidence()}}
(optional if \code{x} is a \code{"seroincidence.by"} object)}

\item{coverage}{Desired confidence interval coverage probability
(default = 0.95)}

\item{verbose}{Logical indicating whether to print verbose messages
(default = FALSE)}

\item{...}{Additional arguments (currently unused)}
}
\value{
\itemize{
\item When comparing two \code{"seroincidence"} objects: An object of class
\code{"htest"} containing the test statistic, p-value, confidence interval,
and estimates.
\item When applied to a \code{"seroincidence.by"} object: A \code{\link[tibble:tibble]{tibble::tibble()}}
with columns for each pair of strata, the difference in incidence rates,
standard error, z-statistic, p-value, and confidence interval bounds.
}
}
\description{
Perform a two-sample z-test to compare seroincidence rates between
two groups. Since we use maximum likelihood estimation (MLE) for each
seroincidence estimate and estimates from different strata or data sets
are uncorrelated, we can use a simple two-sample z-test using the
Gaussian distribution. The standard error for the difference is computed
by adding the estimated variances and taking the square root.
}
\details{
When comparing two single \code{"seroincidence"} objects, this function performs a
two-sample z-test and returns results in the standard \code{htest} format.

When applied to a \code{"seroincidence.by"} object (stratified estimates),
the function compares all pairs of strata and returns a nicely formatted
table with point estimates for the difference in seroincidence, p-values,
and confidence intervals.

The test statistic is computed as:
\deqn{z = \frac{\lambda_1 - \lambda_2}{\sqrt{SE_1^2 + SE_2^2}}}

where \eqn{\lambda_1} and \eqn{\lambda_2} are the estimated incidence rates,
and \eqn{SE_1} and \eqn{SE_2} are their standard errors.
}
\section{Methods (by class)}{
\itemize{
\item \code{compare_seroincidence(seroincidence)}: Compare two single seroincidence
estimates

\item \code{compare_seroincidence(seroincidence.by)}: Compare all pairs of stratified
seroincidence estimates

}}
\examples{
\dontrun{
# See inst/examples/exm-compare_seroincidence.R for complete examples
}
}
