# Using workaround to use censored predictor time-to-event data

**URL:** <https://discourse.mc-stan.org/t/using-workaround-to-use-censored-predictor-time-to-event-data/30577>\
**Category:** brms\
**Tags:** rstan\
**Created:** [March 1, 2023, 10:50am UTC](https://discourse.mc-stan.org/t/using-workaround-to-use-censored-predictor-time-to-event-data/30577 "2023-03-01T10:50:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![l-psych](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/l-psych/32/6980_2.png) [@l-psych](https://discourse.mc-stan.org/u/l-psych)\
**Post date:** [March 1, 2023, 10:50am UTC](https://discourse.mc-stan.org/t/using-workaround-to-use-censored-predictor-time-to-event-data/30577/1 "2023-03-01T10:50:48Z")

</div>

Hi!

I have asked this question in an existing topic ([Survival analysis with right censored and interval censored data with brms - #6 by paul.buerkner](https://discourse.mc-stan.org/t/survival-analysis-with-right-censored-and-interval-censored-data-with-brms/24668/6) ), but haven’t gotten any further as of yet.

I am interested in predicting psychopathology development over time using survival parameters from the survival model.  
I have data collected using ESM in daily life during which individuals reported whether they had stressful events and reported their stress for the rest of the day. My overall goal is to find out whether the time to recovery from stressful events can predict psychopathology development. My analysis plan therefore was as follows:

1. run a survival model to subtract coefs representing individual survival parameters
2. use these individual survival parameters as predictors in the model predicting psychopathology over time in the form of : psychopathology ~ time\*survival\_coefs (of course also including all relevant random effects)

The dataset looks like this:  
**status** (1 = recovered to baseline level of stress / 0 = not recovered within followup time)  
**time1** and **time2** : when status = 1 (recovered): Time 1 and time 2 are interval in which recovery has happened.When **status** = 0 (not recovered) then time1 is the amount of follow-up time during which recovery did not occur  
**SA.b.s** is the level of stress at the time of the event (indicator of how stressful the event was  
**cens** is the censoring variabele I created for the brms model

my data is, if I am not mistaken, both right-censored (not everyone recovers in the follow-up time) and interval censored (we know recovery happened somewhere between time1 and time2, but are not sure exactly which minute).

I am not sure whether I created the censoring variable in the right way. I defined it now as 0=observed recovery and 1=censored (right censored). See sample of the data below:

 ![Screenshot 2022-11-29 at 16.23.01](https://canada1.discourse-cdn.com/flex030/uploads/mc_stan/original/2X/6/6629b3d9585f778bedf58f69d2dd119ff5c4a67b.png)

I formulated my brms syntax as follows:  
fit1 ← brm(time1 | cens(cens, time2) ~ SA.b.s + (1 + SA.b.s |ID)

My questions are:

- does the analysis plan make sense?
- did I create the censoring variable in the right way?
- is the brms code right? especially with regards to the censoring?

Thanks so much in advance!

---

<div class="post-metadata">

**Author:** ![AWoodward](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/awoodward/32/13015_2.png) [@AWoodward](https://discourse.mc-stan.org/u/AWoodward)\
**Post date:** [March 5, 2023, 9:03am UTC](https://discourse.mc-stan.org/t/using-workaround-to-use-censored-predictor-time-to-event-data/30577/2 "2023-03-05T09:03:02Z")

</div>

I’m not sure about this specification for the censoring structure.

If your observations are interval-censored then the censoring label for them is `2`. For mixed censoring with interval and right-censored observations, the observations with `cens == 2` are interval-censored between `time1` and `time2`, `cens == 1` are right-censored at `time1`, and `cens == 0` are not censored (value of the variable is known). So if your row 1 represents a subject who was observed until time 698 but then lost to follow up, and your third row represents a subject whose event occurred sometime between time 1 and time 96, then `cens` for row 3 should be `2`.

Another specification point is that `time2` should not contain any NA. I think any row with NA for any variable in the model will be dropped even if the value wouldn’t be used for that observation.

I also wouldn’t use the column name `cens` because it matches the argument in the formula.

As for the model, I’m not sure. I suppose you could obtain `ID` specific estimates and pass them as data into another model. In principle you could do this with a two-stage approach or with one joint model.

---

<div class="post-metadata">

**Author:** ![l-psych](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/l-psych/32/6980_2.png) [@l-psych](https://discourse.mc-stan.org/u/l-psych)\
**Post date:** [March 21, 2023, 1:27pm UTC](https://discourse.mc-stan.org/t/using-workaround-to-use-censored-predictor-time-to-event-data/30577/3 "2023-03-21T13:27:40Z")

</div>

Thanks so much for your response! I am trying out your adjustments as we speak. I will report back on whether it worked.

---

<div class="post-metadata">

**Author:** ![l-psych](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/l-psych/32/6980_2.png) [@l-psych](https://discourse.mc-stan.org/u/l-psych)\
**Post date:** [April 24, 2023, 5:48pm UTC](https://discourse.mc-stan.org/t/using-workaround-to-use-censored-predictor-time-to-event-data/30577/4 "2023-04-24T17:48:02Z")

</div>

It worked, thanks again!
