% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/check_ph.R
\name{check_ph}
\alias{check_ph}
\title{Check proportional hazards assumption for Cox models}
\usage{
check_ph(
  model,
  transform = c("km", "rank", "identity"),
  alpha = 0.05,
  format = c("flextable", "gt", "tibble")
)
}
\arguments{
\item{model}{A fitted \code{coxph} model or a \code{cox_reg()} object.}

\item{transform}{Time transformation passed to \code{survival::cox.zph()}.
One of \code{"km"}, \code{"rank"}, or \code{"identity"}.}

\item{alpha}{Significance level used for the simple interpretation column.}

\item{format}{Output format. One of \code{"flextable"} (default),
\code{"gt"}, or \code{"tibble"}.}
}
\value{
A tibble, \code{gt_tbl}, or \code{flextable} with Schoenfeld
residual proportional hazards tests. The table contains:
\describe{
  \item{\code{Model}}{Model name. For a direct \code{coxph} object, this is
  \code{"cox_model"}.}
  \item{\code{Term}}{Model term or \code{"GLOBAL"}.}
  \item{\code{Chi.square}}{Chi-square statistic.}
  \item{\code{df}}{Degrees of freedom.}
  \item{\code{p.value}}{Test p-value.}
  \item{\code{Interpretation}}{Simple screening interpretation using
  \code{alpha}.}
}
}
\description{
Test the proportional hazards assumption for fitted Cox proportional hazards
models using Schoenfeld residuals.
}
\details{
\code{check_ph()} is a diagnostic aid for Cox models. A small p-value
suggests possible evidence against the proportional hazards assumption for a
term or for the global model test. This should be interpreted with plots,
clinical knowledge, follow-up patterns, and modelling purpose.
}
\examples{
lung_data <- data_lungcancer
lung_data$trt <- factor(lung_data$trt, levels = c(1, 2),
                        labels = c("Standard", "Test"))

cox_fit <- cox_reg(
  data = lung_data,
  time = time,
  event = status,
  exposures = c(trt, celltype, age)
)

check_ph(cox_fit)
check_ph(cox_fit, format = tibble)

}
