Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/predict.tsglm.R

Predict future observations based on a fitted GLM-type model for time series of counts.

1 2 3 4 5 6 |

`object` |
an object of class |

`n.ahead` |
positive integer value giving the number of steps ahead for which predictions should be made. |

`newobs` |
integer vector of known future observations of the time series. This argument is only relevant if more than one observation ahead is to be predicted ( |

`newxreg` |
matrix or vector containing new values for the covariates to be used for prediction. If |

`level` |
numeric value determining the desired coverage rate of prediction intervals. If |

`global` |
logical value saying whether the coverage rate for |

`type` |
character value saying how the prediction interval shall be constructed. If |

`method` |
character value saying which method to be used for computing the prediction intervals. If |

`B` |
positive integer value giving the number of samples of a parametric bootstrap to use for numerical determination of prediction intervals (only necessary if argument |

`estim` |
character value saying how the prediction intervals shall account for the additional uncertainty induced by the parameter estimation. This is particularly important if the model was fitted on a short time series. If |

`B_estim` |
positive integer value giving the number of parameters used for resampling to account for estimation uncertainty. Only necessary for |

`coefs_given` |
table with parameters in the rows. Only necessary for |

`...` |
further arguments are currently ignored. Only for compatibility with generic function. |

Returns predictions for the `n.ahead`

observations following the fitted time series contained in argument `object`

. The 1-step-ahead prediction is the conditional expectation of the observation to be predicted given the past. The true parameters are replaced by their estimations given in argument `object`

. For a 2-step-ahead-prediction the true previous observation is used when given in argument `newobs`

, otherwise it is replaced by the 1-step-ahead prediction computed before. For a 3-step-prediction this holds for the previous two observations, which are replaced by their respective predictions if not available, and so on.

Unless `level=0`

, the function also returns prediction intervals. Read the description of the arguments `type`

and`method`

for further details on the computation. Note that the prediction intervals do not reflect the additional uncertainty induced by the parameter estimation. However, for sufficiently long time series used for model fitting, it is expected that this uncertainty is negligible compared to the uncertainty of the predictive distribution. The argument `estim`

allows to account fot this additional estimation uncertainty if `method="bootstrap"`

, see the description of this argument.

If prediction intervals are computed the function additionally returns the median of the predictive distribution. If `method="conddistr"`

this is the analytical median of the conditional distribution, otherwise the empirical median of the simulated distribution.

A list with at least the following element:

`pred` |
a numeric vector of the predictions. Has class |

If prediction intervals are calculated, the list has the additional element:

`interval` |
a matrix with the columns |

`level` |
a numeric value determining the desired coverage rate of prediction intervals. |

`global` |
a logical value saying whether the coverage rate |

`type` |
a character value saying how the prediction intervals were computed. Possible values are |

`method` |
a character value saying which method were used for computation of prediction intervals. Possible values are |

`B` |
an integer value giving the number of bootstrap samples which were used for computing prediction intervals. Is |

`estim` |
a character value saying how the prediction intervals account for estimation uncertainty of the model parameters. Possible values are |

`B_estim` |
an integer value giving the number of parameter values used for resampling to account for estimation uncertainty. This value is zero if the estimation uncertainty is ignored. |

`warning_messages` |
a character vector containing warning messages. This should be |

`median` |
a vector giving the median of the predictive distribution for each of the future time points. Has class |

Tobias Liboschik and Philipp Probst

Liboschik, T., Fokianos, K. and Fried, R. (201?) tscount: An R package for analysis of count time series following generalized linear models. *Journal of Statistical Software*, to appear. Available as a vignette: `vignette("tsglm", package="tscount")`

.

`tsglm`

for fitting a GLM for time series of counts.

1 2 3 4 | ```
###Campylobacter infections in Canada (see help("campy"))
campyfit <- tsglm(ts=campy, model=list(past_obs=1, past_mean=c(7,13)))
predict(campyfit, n.ahead=1) #prediction interval using conditional distribution
predict(campyfit, n.ahead=5, global=TRUE) #prediction intervals using parametric bootstrap
``` |

```
$pred
Time Series:
Start = c(2000, 11)
End = c(2000, 11)
Frequency = 13
[1] 10.15617
$interval
Time Series:
Start = c(2000, 11)
End = c(2000, 11)
Frequency = 13
lower upper
2000.769 4 17
$level
[1] 0.95
$global
[1] FALSE
$type
[1] "quantiles"
$method
[1] "conddistr"
$B
NULL
$estim
[1] "ignore"
$B_estim
NULL
$warning_messages
character(0)
$median
Time Series:
Start = c(2000, 11)
End = c(2000, 11)
Frequency = 13
[1] 10
$pred
Time Series:
Start = c(2000, 11)
End = c(2001, 2)
Frequency = 13
[1] 10.15617 11.80326 11.86650 11.83418 11.68767
$interval
Time Series:
Start = c(2000, 11)
End = c(2001, 2)
Frequency = 13
lower upper
2000.769 4 19
2000.846 4 22
2000.923 3 25
2001.000 4 24
2001.077 4 24
$level
[1] 0.95
$global
[1] TRUE
$type
[1] "quantiles"
$method
[1] "bootstrap"
$B
[1] 1000
$estim
[1] "ignore"
$B_estim
[1] 0
$warning_messages
character(0)
$median
Time Series:
Start = c(2000, 11)
End = c(2001, 2)
Frequency = 13
[1] 10 11 11 11 11
```

tscount documentation built on Sept. 30, 2017, 5:06 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.