*! version 1.6 20150617
help stphcoxrcs

Title

stphcoxrcs - Check proportional-hazards assumption using restricted cubic splines

Syntax

stphcoxrcs varname [, stphcoxrcs_options]

stphcoxrcs_options

Main
nknots(#) specifies the number of knots for the restricted cubic spline transformations of ln(analysis time); default is nknots(3)

splitevery(#) splits records when analysis time is a multiple of #

splitat(numlist) splits records at specified analysis times; default is splitat(failures)

Other
lrtest performs a likelihood ratio test on the interaction terms instead of a Wald test

ic displays Akaike's and Schwarz's Bayesian information criteria

Plot
level(#) sets confidence level; default is level(95)

noci suppresses the confidence intervals

noyref suppresses the reference line (Hazard Ratio = 1.00)

lntime plots the Hazard Ratio according to ln(analysis time)

nograph suppresses graph

range(# #) specifies the range for analysis time

gopts(twoway_options) modifies the graph

saving(filename [, replace]) saves a dataset with the variables needed to reproduce the graph of the time-varying hazard ratio

Note: You must stset your data using the id() option before using stphcoxrcs

Description

stphcoxrcs checks the proportional-hazards assumption for one covariate of interest (binary or continuous) after fitting a model with stcox. In particular, stphcoxrcs models the natural logarithm of analysis time using restricted cubic splines transformations, which are interacted with the covariate specified in varname. A joint Wald (default) or likelihood ratio test of all the interaction terms is carried out to test the proportional-hazards assumption. Lastly, stphcoxrcs produces a graph of the time-varying Hazard Ratio.

Options for stphcoxrcs

Main

nknots(#) specifies the number of knots for the restricted cubic spline transformations of log analysis time. The number of knots must be between 3 (default) and 5. The default knot positions are based on Harrell's recommended percentiles of the distribution of the uncensored natural logarithm of analysis time. See mkspline.

splitevery(#) splits the records a each positive multiple of #. See stsplit.

splitat(numlist) splits records at specified analysis times; splitat(failures) splits the records at failure times (default). See stsplit.

Other

lrtest performs a likelihood ratio test on all the interaction terms instead of a Wald test.

ic displays Akaike's and Schwarz's Bayesian information criteria.

Plot

level(#); see [R] estimation options.

noci suppresses the confidence intervals for the time-varying Hazard Ratio.

noyref suppresses the reference line at Hazard Ratio = 1.00.

lntime specifies that the time-varying Hazard Ratio is plotted against the natural logarithm of analysis time (instead of analysis time itself).

nograph suppresses displaying the graph.

range(# #) specifies the range for analysis time.

gopts(twoway_options) are any of the options documented in twoway_options.

saving(filename [, replace]) saves in a separate .dta file the variables needed to reproduce the graph of the time-varying Hazard Ratio. The dataset contains the following variables: Hazard Ratio, upper and lower confidence interval bounds, and analysis time.

Examples

use http://www.biostatepi.org/data/hers, clear

stset pafu, f(pa) id(id)

stcox group

stphcoxrcs group, splitevery(.2) nknots(3) range(.25 6) noyref

References

Heinzl, H., & Kaider, A. (1997). Gaining more flexibility in Cox proportional hazards regression models with cubic spline functions. Computer methods and programs in biomedicine, 54(3), 201-208.

Therneau, T. M., & Grambsch, P. M. (2000). Modeling survival data: extending the Cox model. Springer-Verlag. New York.

Royston, P., & Lambert, P. C. (2011). Flexible parametric survival analysis using Stata: beyond the Cox model. Stata Press books.

Authors

Andrea Discacciati

Unit of Nutritional Epidemiology

Unit of Biostatistics

Institute of Environmental Medicine, Karolinska Institutet

Stockholm, Sweden

Viktor Oskarsson

Unit of Nutritional Epidemiology

Institute of Environmental Medicine, Karolinska Institutet

Stockholm, Sweden

Nicola Orsini

Unit of Nutritional Epidemiology

Unit of Biostatistics

Institute of Environmental Medicine, Karolinska Institutet

Stockholm, Sweden

Support

andrea.discacciati@ki.se

Saved results

stphcoxrcs saves the following in r():

Scalars

e(chi2) chi-squared statistic

e(df) test constraints degrees of freedom

e(p) p-value

e(N_knots) number of knots

Matrices

r(S) 1 x 6 matrix of results:

1. sample size 4. degrees of freedom
2. log likelihood of null model 5. AIC
3. log likelihood of full model 6. BIC