In R, I am trying to use a Weibull model to generate predictions of the time to an event, conditional on a set of time-varying covariates and survival to time *t*. This is partly a coding question, but it's also a methods question, and I can't share my data to make a reproducible example, so I thought I would post it here instead of Stack Overflow.

Using `survreg`

, I can get predicted responses from a fitted model for any given vector of covariate values. The predictions produced by `predict(fitted.weibull.model, type = 'response')`

, however, appear to be unconditional, i.e., not tied to the survival times reported in the associated rows. That's true whether I'm computing in-sample estimates or applying the model to new data.

I had assumed, apparently incorrectly, that for parametric models `predict.survreg`

would also account for the model-estimated duration dependency. For example, if the model showed a secular increase in the likelihood of event occurrence with the passage of time, then a series of predicted responses generated from that model for a given individual would shrink as her survival time increased, assuming that other time-varying covariates remained constant. But that's not what I see in my results.

Is this even a thing? If so, is there a canned way to do this in R, or is it one of those things where you've got to roll your own function to combine the unconditional predictions with the duration-dependency component to get forecasts conditional on observed survival times? If it's a roll-your-own situation, can anyone point me toward a worked example, ideally but not necessarily in R? My searches have come up empty.

## Best Answer

Although I don't have a solution that involves

`survreg`

, the`spduration`

package has split-population duration regression models that allow you to predict conditional ontand a set of time-varying covariates. Here is an example using code from`?spdur`

, which estimates a model of the time to a successful coup d'etat, using polity 2 regime scores as the only predictor in both the duration and risk equations:The resulting plot shows how the conditional hazard for countries with different Polity2 values (that themselves are constant over time) evolve over assumed survival time

t:The plot is more complicated than one might expect with a Weibull hazard shape because the predictor Polity2 is in both the duration and risk equations. There is no plain Weibull regression in the package, the closest is probably a model with a constant-only risk equation that keeps Polity2 in the duration equation:

Which produces this plot:

Lastly, here is an example that shows that the predictions respond now only over changing

tvalues, but also to shifts in the time-varying covariate over the prediction period: