 Forecast - Maple Help

TimeSeriesAnalysis

 Forecast
 forecast a time series using an exponential smoothing model Calling Sequence Forecast(model, n, extraparameters, opts) Forecast(model, ts, n, extraparameters, opts) Parameters

 model - ts - Time series consisting of a single data set n - nonnegative integer indicating how many data points should be forecast extraparameters - (optional) table of parameter values opts - (optional) equation(s) of the form optionname = value, where optionname is one of output, runs, and evolve Description

 • The Forecast command generates a forecast for a time series using an exponential smoothing model.
 • If a time series is not specified in the calling sequence, then the time series that model is created from will be used.
 • The number n is the number of data points that will be forecast.
 • The value of any of the parameters can be overridden by supplying the extraparameters option. It is a table in the format returned by Initialize: its indices are global names corresponding to parameters, and the values are their values as explained in the Exponential smoothing model help page. Options

 • output= point, runs, percentiles(p1, p2, ..., pn), quantiles(q1, q2, ..., qn), or confidenceintervals(c1, c2, ..., cn)
 By default, Maple will generate a point forecast by assuming the future residuals will all be $0$. Other forms of output can be selected using the output option.
 – output = percentiles(p1, p2, ..., pn) returns $n$ time series that represent the p1th, p2th, ..., pnth percentile of the distribution of the values generated by the model. This is obtained via simulation.
 – output = quantiles(q1, q2, ..., qn) returns $n$ time series that represent the q1th, q2th, ..., qnth quantile of the distribution of the values generated by the model. The only difference with percentiles is that, e.g., p1 = 5 will be interpreted in the same way as q1 = 0.05.
 – output = confidenceintervals(c1, c2, ..., cn) returns $2n+1$ time series: the 50 - ci/2 and 50 + ci/2 percentiles for i from 1 to n, and the 50th percentile. For example, confidenceintervals(80, 95) will return the $2.5$, $10$, $50$, $90$, and $97.5$ percentiles.
 – output = runs returns all simulated future time series. This requires that the runs = k option is also included. (See below.)
 – output = point selects the default behavior of point forecasts obtained by setting all future residuals to $0$.
 • runs= nonnegative integer
 For any setting of the output option other than point, Maple will run multiple forecasts. The runs option determines the number of forecasts used to arrive at this output. If output is of the form percentiles(p1, p2, ..., pn) or quantiles(q1, q2, ..., qn) or confidenceintervals(c1, c2, ..., cn), then by default, Maple chooses the number of runs between $50$ and $2000$ depending on the particular values chosen. For example, for percentiles(10, 50, 70), the default number of runs is $225$. The runs option overrides this default. It is a required option if output = runs is selected: there is no default value. If output = point, then the runs option is ignored.
 • evolve= true, false, or a nonnegative integer
 Normally, the values of the model parameters represent the model at the beginning of the time series, and the values we would like to forecast are after the end of the time series. In this case, the state of the model needs to evolve through the time series in order to obtain the state at the end. This is the default behavior. If you would like to use the model as is, you can supply the option evolve = false. If you want the model to evolve only a limited number of steps, say k, you can supply the option evolve = k. All of this applies only to evolution of the model before the actual forecast is started. Examples

 > $\mathrm{with}\left(\mathrm{TimeSeriesAnalysis}\right):$

Consider the following time series. It represents international tourist visitor nights in Australia.

 > $\mathrm{ts}≔\mathrm{TimeSeries}\left(⟨41.7,24.0,32.3,37.3,46.2,29.3,36.5,43.0,48.9,31.2,37.7,40.4,51.2,31.9,41.0,43.8,55.6,33.9,42.1,45.6,59.8,35.2,44.3,47.9⟩,\mathrm{startdate}="2005",\mathrm{frequency}=\mathrm{quarterly},\mathrm{header}="Visitor nights"\right)$
 ${\mathrm{ts}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{Visitor nights}}\\ {\mathrm{24 rows of data:}}\\ {\mathrm{2005-Jan-01 - 2010-Oct-01}}\end{array}\right]$ (1)

Fit an exponential smoothing model to it.

 > $\mathrm{esm}≔\mathrm{ExponentialSmoothingModel}\left(\mathrm{ts}\right)$
 ${\mathrm{TimeSeriesAnalysis}}{:-}{\mathrm{ExponentialSmoothingModel}}{}\left({\mathrm{errors}}{=}\left\{{"M"}\right\}{,}{\mathrm{trend}}{=}\left\{{"A"}\right\}{,}{\mathrm{seasonal}}{=}\left\{{"M"}\right\}{,}{\mathrm{α}}{=}{0.4836790988889591}{,}{\mathrm{β}}{=}{0.0003088251694408857}{,}{\mathrm{γ}}{=}{0.00023143579040411943}{,}{\mathrm{φ}}{=}{1.}{,}{\mathrm{period}}{=}{4}{,}{\mathrm{l0}}{=}{31.691916154639692}{,}{\mathrm{b0}}{=}{0.6527296503176275}{,}{s}{=}\left(\left[\begin{array}{c}1.2641437853861655\\ 0.7602113492955748\\ 0.946057915985054\\ 1.0295918919494698\end{array}\right]\right){,}{\mathrm{σ}}{=}{0.03343189749472918}{,}{\mathrm{constraints}}{=}{"both"}\right)$ (2)

Now get the point forecast of this model for two years.

 > $\mathrm{pfc}≔\mathrm{Forecast}\left(\mathrm{esm},8\right)$
 ${\mathrm{pfc}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{Visitor nights \left(forecast\right)}}\\ {\mathrm{8 rows of data:}}\\ {\mathrm{2010-Dec-31 - 2012-Sep-30}}\end{array}\right]$ (3)
 > $\mathrm{TimeSeriesPlot}\left(\mathrm{ts},\left[\mathrm{pfc},\mathrm{color}="Red"\right]\right)$ Or specify the time series explicitly.

 > $\mathrm{pfc2}≔\mathrm{Forecast}\left(\mathrm{esm},\mathrm{ts},8\right)$
 ${\mathrm{pfc2}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{Visitor nights \left(forecast\right)}}\\ {\mathrm{8 rows of data:}}\\ {\mathrm{2010-Dec-31 - 2012-Sep-30}}\end{array}\right]$ (4)
 > $\mathrm{TimeSeriesPlot}\left(\mathrm{ts},\left[\mathrm{pfc2},\mathrm{color}="Red"\right]\right)$ > $\mathrm{cis}≔\mathrm{Forecast}\left(\mathrm{esm},8,\mathrm{output}=\mathrm{confidenceintervals}\left(80,95\right)\right)$
 ${\mathrm{cis}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{Visitor nights \left(forecast - 2 percentile\right), ..., Visitor nights \left(forecast - 98 percentile\right)}}\\ {\mathrm{8 rows of data:}}\\ {\mathrm{2010-Dec-31 - 2012-Sep-30}}\end{array}\right]$ (5)
 > $\mathrm{TimeSeriesPlot}\left(\mathrm{ts},\left[\mathrm{cis},\mathrm{color}="Red".."Green"\right]\right)$ If you use a larger number of runs, the confidence intervals will be slightly more accurate.

 > $\mathrm{cis2}≔\mathrm{Forecast}\left(\mathrm{esm},8,\mathrm{output}=\mathrm{confidenceintervals}\left(80,95\right),\mathrm{runs}=5000\right)$
 ${\mathrm{cis2}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{Visitor nights \left(forecast - 2 percentile\right), ..., Visitor nights \left(forecast - 98 percentile\right)}}\\ {\mathrm{8 rows of data:}}\\ {\mathrm{2010-Dec-31 - 2012-Sep-30}}\end{array}\right]$ (6)
 > $\mathrm{TimeSeriesPlot}\left(\mathrm{ts},\left[\mathrm{cis2},\mathrm{color}="Red".."Green"\right]\right)$ You can also see how the model would forecast the data of 2009-2010. That means you need to evolve the model for only four years, or 16 time steps, before starting to forecast.

 > $\mathrm{cis3}≔\mathrm{Forecast}\left(\mathrm{esm},8,\mathrm{evolve}=16,\mathrm{output}=\mathrm{confidenceintervals}\left(80,95\right)\right)$
 ${\mathrm{cis3}}{≔}\left[\begin{array}{c}{\mathrm{Time series}}\\ {\mathrm{Visitor nights \left(forecast - 2 percentile\right), ..., Visitor nights \left(forecast - 98 percentile\right)}}\\ {\mathrm{8 rows of data:}}\\ {\mathrm{2009-Jan-01 - 2010-Oct-01}}\end{array}\right]$ (7)
 > $\mathrm{TimeSeriesPlot}\left(\left[\mathrm{ts},\mathrm{thickness}=3\right],\left[\mathrm{cis3},\mathrm{color}="Red".."Green",\mathrm{transparency}=0.25\right]\right)$ > References

 Hyndman, R.J. and Athanasopoulos, G. (2013) Forecasting: principles and practice. http://otexts.org/fpp/. Accessed on 2013-10-09.
 Hyndman, R.J., Koehler, A.B., Ord, J.K., and Snyder, R.D. (2008) Forecasting with Exponential Smoothing: The State Space Approach. Springer Series in Statistics. Springer-Verlag Berlin Heidelberg. Compatibility

 • The TimeSeriesAnalysis[Forecast] command was introduced in Maple 18.