Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Cubic splines in stcox

From   Steve Samuels <>
Subject   Re: st: Cubic splines in stcox
Date   Fri, 4 Jan 2013 20:49:40 -0500

Marc Peters  <>:

No version of spline is going to "fix" your problem. Your model is
failing precisely because you are fitting spline function(s) in year,
which is the time dimension of the -stcox- model-. -stcox- is
already fitting a flexible model in time, so the spline function(s) and
year are likely to be nearly collinear. When this happens, the partial
likelihood will not converge.

For a simple example with n =3, see Example 1 of:

Maximum Likelihood Inference for the Cox Regression Model with
Applications to Missing Covariates Ming-Hui Chen, Joseph G. Ibrahim, and
Qi-Man Shao. J Multivar Anal. 2009 October 1; 100(9): 2018–2030.

This is available at:

Your spline functions probably violate at least condition C2 of their
Theorem 1.

You'd probably see your mistake more clearly if, instead of -stcox- you
fit -stpm- by Patrick Royston, or its extension,-stpm2- by Paul Lambert,
both available at SSC. These commands use splines in the the time
variable to fit the underlying survival functions. Your own functions
would be collinear with these.

You _can_ fit functions of time in -stcox- but only as interactions with
other predictors, not as main effects.


On Fri, Jan 4, 2013 at 10:42 AM, Marc Peters <> wrote:
> Dear Statalist users,
> I am new to event history models and am estimating a Cox proportional
> hazard model, with civil war as the dependent variable. the dependent
> variable is measured at discrete intervals (yearly).
> My basic model is estimated using the following syntax:
> stset year, failure(cwar)
> stcox dem gdp, cluster (country)
> This model runs well, but I encounter problems when including cubic
> splines, using this syntax:
> mkspline sp_year=year, cubic nknots(3)
> stcox dem gdp sp_year*, cluster (country)
> When running the command I get the following message "flat region
> resulting in a missing likelihood"
> I am sure this is a very trivial question, but I would greatly
> appreciate if anyone could help me in explaining what the problem is
> and how I might fix it.
> Thank you,
> Marc

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index