% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/diagnostics.R
\name{hzr_bootstrap}
\alias{hzr_bootstrap}
\alias{print.hzr_bootstrap}
\title{Bootstrap resampling for hazard model coefficients}
\usage{
hzr_bootstrap(
  object,
  n_boot = 200L,
  fraction = 1,
  seed = NULL,
  verbose = FALSE
)

\method{print}{hzr_bootstrap}(x, digits = 4, ...)
}
\arguments{
\item{object}{A fitted \code{hazard} object (with \code{fit = TRUE}).}

\item{n_boot}{Integer: number of bootstrap replicates (default 200).}

\item{fraction}{Numeric in (0, 1]: fraction of data to sample per
replicate (default 1.0 for full bootstrap; < 1 for bagging).}

\item{seed}{Optional integer random seed for reproducibility. When
supplied, \code{set.seed(seed)} is called at function entry, jumping the
global RNG to the seeded state; it is not restored on exit. Pass
\code{NULL} (the default) to skip the \code{set.seed()} call and start from
the caller's current RNG state. Note that the bootstrap consumes
random numbers either way, so the global RNG state will advance
during the call -- \code{seed = NULL} avoids the \emph{reset} at entry, not
the advance during resampling.}

\item{verbose}{Logical; if \code{TRUE}, print progress every 50 replicates.}

\item{x}{An \code{hzr_bootstrap} object.}

\item{digits}{Number of decimal places for formatting.}

\item{...}{Additional arguments (ignored).}
}
\value{
A list with class \code{"hzr_bootstrap"} containing:
\describe{
\item{replicates}{Data frame with columns \code{replicate}, \code{parameter},
and \code{estimate} -- one row per parameter per successful replicate.}
\item{summary}{Data frame with columns \code{parameter}, \code{n}, \code{pct},
\code{mean}, \code{sd}, \code{min}, \code{max}, \code{ci_lower}, \code{ci_upper} -- one row per
parameter.}
\item{n_success}{Number of successfully converged replicates.}
\item{n_failed}{Number of replicates that failed to converge.}
}
}
\description{
Resample data with replacement, refit the hazard model on each
replicate, and accumulate coefficient distributions. Returns a tidy
data frame of per-replicate estimates with summary statistics.
This is the R equivalent of the SAS \code{bootstrap.hazard.sas} macro.
}
\examples{
\donttest{
data(avc)
avc <- na.omit(avc)
fit <- hazard(
  survival::Surv(int_dead, dead) ~ age + mal,
  data  = avc,
  dist  = "weibull",
  theta = c(mu = 0.01, nu = 0.5, 0, 0),
  fit   = TRUE
)
bs <- hzr_bootstrap(fit, n_boot = 50, seed = 123)
print(bs)
}

}
\seealso{
\code{\link[=hazard]{hazard()}} for model fitting, \code{\link[=vcov.hazard]{vcov.hazard()}} for
Hessian-based standard errors.
}
