I'm interested in predicting when a customer will churn, after they've turned a certain age (in this case, age 18, but this could really be any number).

This piece is critical: given the domain being modeled, as someone gets older, their likelihood of churning should increase (this is domain-specific knowledge one would expect to surface in whatever model is produced).

However, so far my attempts at using a Cox Proportional Hazards model–using the approach I've outlined in the diagram below–have yielded the opposite: older people are less likely to churn (i.e. the covariate age has a negative coefficient, where churning is the "event").

I think the issue relates to the point at which I'm pulling the age covariate for each individual: for uncensored records (i.e. those who churned), I pulled their age as of the person's first appearance in the study; for censored records (i.e. those who didn't churn within the study period), my first approaches had me pulling their ages as of each individual's last observation in the study period. To be frank, I'm brand-new to survival analysis and am not entirely sure why I this was my first approach; I, for whatever reason, was under the impression that all covariates should be pulled as of the most recent time period for censored individuals. However, I'm coming to doubt that understanding, given the unintuitive sign attached to my age coefficient.

So my question is: in the dataset/approach described above and in the diagram below, with a variety of potential censor statuses, when should key covariates like age be pulled and attached to the dependent variable ("years until churn")? Should those green Xs for the right-censored records be shifted all the way to the left, instead of calculating age right before censorship/the end of the study?

Example survival dataset

  • $\begingroup$ I think you have interval censored data which is one way to handle your problem. $\endgroup$
    – forecaster
    Jun 10, 2023 at 20:25

1 Answer 1


The inconsistency in handling the age predictor between those who churned and those who didn't probably accounts for your unexpected modeled association between age and risk of churning. Altering any predictor based on whether or not there was an event recorded will get you into trouble in survival analysis.

A Cox model is fit based on the covariate values in place for all individuals at risk at each event time. So if you use a larger constant age value for someone who didn't churn than you would have used if she did churn, you are imposing something similar to survivorship bias on your model. In your case, you specified older ages for those who didn't churn than you should have, so it's not surprising that the model was fooled into thinking that a higher age is associated with less risk of churn.

One way to handle age as a predictor is to enter the value at study entry as a covariate for all individuals. In fact, if you code age that way and model age as a simple linear predictor with respect to log-hazard of churning, then the way that Cox models are fit will handle the changing age values over time directly. In that case, you are modeling both age at study entry and current age as the predictor. See Section 5 of the R vignette on time-dependent survival models for an explanation.

If you want to model age more flexibly (e.g., with a regression spline), then you need to decide, based on your subject matter knowledge, whether you want to use age at study entry or current age as the predictor. For the former, just code the age predictor as the age at study entry.

For the latter, you need to structure the data in the extended "counting process" format and treat age as a time-varying covariate, with a separate row for each individual's time interval corresponding to each set of covariate values, including a start and stop time for the interval and an indicator of whether the event occurred at the stop time. The above vignette section explains how to do that.

  • $\begingroup$ How would this age calculation work for people like Ricky, who is 22 years old as of the study's start, and I have no information on him prior to the beginning of the study? Could calculating his age as of study entry lead to survivorship bias as well, given the domain knowledge that as someone gets older they're more likely to have churned (and perhaps never need the product I or any of my competitors offer)? $\endgroup$ Jun 12, 2023 at 14:14
  • 1
    $\begingroup$ @blacksite someone like Ricky would be considered to provide "left truncated" data: Ricky's data provide no information on what might have happened prior to age 22 for someone who already was enrolled in the service. That's handled correctly by the "counting process" data format also used for time-varying covariates. Each data row has a start time (age at study entry in this case), a stop time (for churn date/last follow up) and an indicator of churn/no-churn at the stop time. See the R survival vignette. $\endgroup$
    – EdM
    Jun 12, 2023 at 14:48
  • 1
    $\begingroup$ @blacksite my suggestion for handling left-truncated data would work if you were using age as the time scale. Think carefully about your time origin for the survival analysis. It might make the most sense to use the date of original enrollment as time=0 and impose the left truncation at the time from that to your "measurement start date." $\endgroup$
    – EdM
    Jun 12, 2023 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.