`forecast`

method for `spdur`

class objects.

# S3 method for spdur forecast(object, ..., pred.data = NULL, stat = "conditional hazard", n.ahead = 6)

object | A |
---|---|

… | Optional arguments, not used. |

pred.data | Data on which to base forecasts, i.e. slice of last time unit's observations for all cross-sectional units. |

stat | Which statistic to forecast, see |

n.ahead | How many time periods to predict ahead. Default is 6. |

This function will create out-of-sample predictions of ``stat''
using model estimates and the prediction data provided. It is assumed that
prediction data consist of a slice of the last time period observed for
the data used to estimate the model in `object`

. For each row,
`forecast.spdur`

will estimate the model predictions for that time point
and then extrapolate the resulting probability to `n.ahead`

time
periods using appropriate probability theory.

For situations in which the covariate values are known for future time
periods, e.g. in a test sample use `predict.spdur`

instead.

library(forecast) data(coups) data(model.coups) coups.dur <- add_duration(coups, "succ.coup", "gwcode", "year", freq="year") pred.data <- coups.dur[coups.dur$year==max(coups.dur$year), ] pred.data <- pred.data[complete.cases(pred.data), ] fcast <- forecast(model.coups, pred.data=pred.data)