% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/WA-estimands.R
\name{WA_reg}
\alias{WA_reg}
\title{While-Alive Regression for Recurrent Events}
\usage{
WA_reg(
  formula,
  data,
  time = NULL,
  cens.code = 0,
  cause = 1,
  death.code = 2,
  marks = NULL,
  ...,
  trans = 1
)
}
\arguments{
\item{formula}{Formula with regression design. The first covariate on the RHS must 
be the treatment factor. Can include other covariates and \code{cluster(id)}.}

\item{data}{Data frame.}

\item{time}{Time point \eqn{t} for estimation.}

\item{cens.code}{Censoring code.}

\item{cause}{Event cause code.}

\item{death.code}{Death code.}

\item{marks}{Marks for composite outcomes.}

\item{...}{Additional arguments passed to \code{binreg}.}

\item{trans}{Power transformation for the outcome (default 1).}
}
\value{
An object of class \code{"binreg"} containing coefficient estimates, 
  standard errors, confidence intervals, and influence functions for the 
  regression of the event rate per time alive.
}
\description{
Performs regression analysis for the "While-Alive" mean of events per time unit, 
defined as \eqn{Z(t) = N(\min(D,t)) / \min(D,t)}. This function models how covariates 
affect the rate of recurrent events per unit of time alive.
}
\details{
The estimation is based on IPCW (Inverse Probability of Censoring Weighting) and 
calls \code{binreg} after constructing the outcome variable. It supports double 
robust estimation if covariate augmentation is specified.
}
\examples{
data(hfactioncpx12)
hfactioncpx12$age <- rnorm(741)[hfactioncpx12$id] 
dtable(hfactioncpx12,~status)
## exp-link regression 
dd <- WA_reg(Event(entry,time,status)~treatment+age+cluster(id),data=hfactioncpx12,
                    time=2,death.code=2)
summary(dd)
}
\references{
Ragni, A., Martinussen, T., & Scheike, T. H. (2023). Nonparametric estimation of the Patient Weighted While-Alive Estimand. arXiv preprint.
}
\author{
Thomas Scheike
}
