% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/assoc.R
\name{assoc_coxph_zph}
\alias{assoc_coxph_zph}
\alias{assoc_zph}
\title{Proportional hazards assumption test for Cox regression}
\usage{
assoc_coxph_zph(
  data,
  outcome_col,
  time_col,
  exposure_col,
  covariates = NULL,
  base = TRUE,
  strata = NULL
)

assoc_zph(
  data,
  outcome_col,
  time_col,
  exposure_col,
  covariates = NULL,
  base = TRUE,
  strata = NULL
)
}
\arguments{
\item{data}{(data.frame or data.table) Analysis dataset.}

\item{outcome_col}{(character) Binary event indicator (\code{0}/\code{1}
or \code{TRUE}/\code{FALSE}).}

\item{time_col}{(character) Follow-up time column name.}

\item{exposure_col}{(character) One or more exposure variable names.}

\item{covariates}{(character or NULL) Covariates for the Fully adjusted
model. Default: \code{NULL}.}

\item{base}{(logical) Include Unadjusted and Age and sex adjusted models.
Default: \code{TRUE}.}

\item{strata}{(character or NULL) Optional stratification variable.}
}
\value{
A \code{data.table} with one row per exposure \eqn{\times} term
\eqn{\times} model combination, and columns:
\describe{
\item{\code{exposure}}{Exposure variable name.}
\item{\code{term}}{Coefficient name.}
\item{\code{model}}{Ordered factor: \code{Unadjusted} <
\code{Age and sex adjusted} < \code{Fully adjusted}.}
\item{\code{chisq}}{Schoenfeld residual chi-squared statistic.}
\item{\code{df}}{Degrees of freedom.}
\item{\code{p_value}}{P-value for the PH test (term-level).}
\item{\code{ph_satisfied}}{Logical; \code{TRUE} if \code{p_value > 0.05}.}
\item{\code{global_chisq}}{Global chi-squared for the whole model.}
\item{\code{global_df}}{Global degrees of freedom.}
\item{\code{global_p}}{Global p-value for the whole model.}
}
}
\description{
Tests the proportional hazards (PH) assumption using Schoenfeld residuals
via \code{\link[survival]{cox.zph}}. Re-fits the same models as
\code{\link{assoc_coxph}} (same interface) and returns a tidy result table
with term-level and global test statistics.
}
\details{
A non-significant p-value (p > 0.05) indicates the PH assumption is
satisfied for that term. The global test (\code{global_p}) reflects the
overall PH assumption for the whole model.
}
\examples{
dt <- ops_toy(scenario = "association", n = 500)
dt <- dt[dm_timing != 1L]

zph <- assoc_coxph_zph(
  data         = dt,
  outcome_col  = "dm_status",
  time_col     = "dm_followup_years",
  exposure_col = "p20116_i0",
  covariates   = c("bmi_cat", "tdi_cat"),
  base         = FALSE
)
zph[ph_satisfied == FALSE]
}
