% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lpr_ci.R
\name{lpr_ci}
\alias{lpr_ci}
\title{Compute Design-Based Proportion and Confidence Interval}
\usage{
lpr_ci(
  data,
  outcome,
  weight = "weight1500",
  strata = NULL,
  psu = NULL,
  conf.level = 0.95,
  na.rm = TRUE
)
}
\arguments{
\item{data}{A data frame containing the outcome and survey design variables.}

\item{outcome}{Character string. Name of a binary variable coded 0/1.}

\item{weight}{Character string. Name of the sampling weight variable.
Default is `"weight1500"`.}

\item{strata}{Character string. Name of the stratification variable.
Default is `NULL`. If provided together with `psu`, a complex survey
design is used.}

\item{psu}{Character string. Name of the primary sampling unit (cluster)
variable. Default is `NULL`.}

\item{conf.level}{Numeric. Confidence level for the interval.
Default is `0.95`.}

\item{na.rm}{Logical. If `TRUE`, rows with missing values in the
required variables are removed prior to estimation.}
}
\value{
A data frame with:
\describe{
  \item{prop}{Estimated proportion (mean of binary outcome).}
  \item{lb}{Lower bound of the confidence interval.}
  \item{ub}{Upper bound of the confidence interval.}
  \item{se}{Standard error of the estimate.}
}
}
\description{
Computes a weighted proportion (mean of a binary outcome) and its
confidence interval using complex survey design features. When
stratification and PSU variables are supplied, the function uses
Taylor linearized variance estimation via the \pkg{survey} package.
}
\details{
If both `strata` and `psu` are provided, a full complex survey design
is declared. If they are `NULL`, the function computes a weighted
estimate assuming simple random sampling (SRS) with weights.

Lonely PSUs are handled using `survey.lonely.psu = "adjust"`.


Variance estimation is performed using Taylor linearization as implemented
in \code{\link[survey]{svymean}}. When both `strata` and `psu` are supplied,
clustering and stratification are incorporated in the variance estimator.

If `strata` and `psu` are not provided, the function assumes a weighted
simple random sample and estimates variance accordingly.
}
\examples{
\donttest{
# Design-based estimate
data(cm23)
lpr_ci(data = cm23,
         outcome = "b13",
         weight = "weight1500",
         strata = "strata",
         psu = "upm")

# Weighted SRS estimate
data(bra23)
lpr_ci(data = bra23,
         outcome = "b13",
         weight = "wt")
}

}
