*! version 1.0.0 06apr2026

Title

finegray_phtest -- Test proportional subdistribution hazards assumption

Syntax

finegray_phtest
[, options]

time(function) time function: rank (default), log, or identity

detail display scaled Schoenfeld residuals

Description

finegray_phtest tests the proportional subdistribution hazards (PSH) assumption after finegray. It computes scaled Schoenfeld residuals at each cause-event time and tests their correlation with a function of time.

Under the PSH assumption, the scaled Schoenfeld residuals should be uncorrelated with time. A significant test indicates that the effect of the corresponding covariate changes over time, violating the PSH assumption.

The per-variable tests use scaled Schoenfeld residuals correlated with a time function, similar in spirit to estat phtest after stcox. However, the implementation differs in two ways: (1) scaling uses only the diagonal of the inverse information matrix rather than the full matrix, and (2) the global test is the sum of the per-variable chi-squared statistics, which ignores cross-covariate covariance. This makes the global test an approximate PH diagnostic rather than a joint test. Results are most reliable when covariates are approximately orthogonal. When finegray-created _fg_* factor-variable columns have been dropped, the command reconstructs them on demand and retains the underlying factor term names in output and r(phtest) rownames.

Data requirement: finegray_phtest computes Schoenfeld residuals on the estimation sample and therefore requires the original stset data — specifically _t, _d, and a nonempty estimation sample (e(sample)). Unlike finegray_predict, xb, it cannot be run after loading a new dataset.

Options

time(function) specifies the time function used in the correlation test. rank (the default) uses the rank of event times. log uses log(time). identity uses raw event times. The rank transformation is robust to outliers and is the standard choice.

detail displays the first 20 rows of the scaled Schoenfeld residual matrix.

Examples

Setup

. webuse hypoxia, clear

. gen byte status = failtype

. stset dftime, failure(dfcens==1) id(stnum)

. finegray ifp tumsize pelnode, compete(status) cause(1)

Default PH test (rank of time)

. finegray_phtest

Log-time transformation

. finegray_phtest, time(log)

Display residuals

. finegray_phtest, detail

Stored results

finegray_phtest stores the following in r():

Scalars

r(chi2) global chi-squared statistic

r(df) degrees of freedom

r(p) global p-value

r(N_fail) number of cause events

Macros

r(time) time function used

Matrices

r(phtest) p x 3 matrix: chi2, df, p for each variable

Author

Timothy P Copeland, Karolinska Institutet

Version 1.0.0, 2026-04-06

Report bugs and suggestions at

https://github.com/tpcopeland/Stata-Tools

Also see

Online: finegray, finegray_predict, stcrreg, stcox, stset