Tests the proportional hazards assumption for Cox regression models using Schoenfeld residuals (cox.zph test).
Usage
test_ph_assumption(
data,
time_var = NULL,
event_var = NULL,
trt_var = "TRT01P",
covariates = character(),
alpha = 0.05,
plot = FALSE
)Arguments
- data
An ADaMData object (with domain "ADTTE") or an ADTTE data frame with time-to-event data, or a coxph model object
- time_var
Character. Time variable (required if data is a data frame)
- event_var
Character. Event variable (required if data is a data frame)
- trt_var
Treatment variable name (default: "TRT01P"). Ignored for ADaMData objects which use their own trt_var property.
- covariates
Character vector. Additional covariates to include
- alpha
Numeric. Significance level for flagging violations (default: 0.05)
- plot
Logical. Whether to create diagnostic plot (default: FALSE)
Value
A list with:
results: Data frame with variable, rho, chisq, p-value, violation flag
global_test: Global test result (p-value)
violation: Logical, TRUE if any p < alpha
model: The fitted coxph model
zph: The cox.zph result object
plot: ClinicalPlot if plot=TRUE
