TimeSeriesForecast[tproc,data,k]
gives the k-step-ahead forecast beyond data according to the time series process tproc.
TimeSeriesForecast[tsmod,k]
gives the k-step-ahead forecast for TimeSeriesModel tsmod.
TimeSeriesForecast
TimeSeriesForecast[tproc,data,k]
gives the k-step-ahead forecast beyond data according to the time series process tproc.
TimeSeriesForecast[tsmod,k]
gives the k-step-ahead forecast for TimeSeriesModel tsmod.
Details and Options
- TimeSeriesForecast[tproc,{x0,…,xm},k] will give Expectation[x[m+k]x[0]x0∧…∧x[m]xm], where xtproc, the expected value of the process given data.
- TimeSeriesForecast allows tproc to be a time series process such as ARProcess, ARMAProcess, SARIMAProcess, etc.
- The data can be a list of numeric values {x1,x2,…}, a list of time-value pairs {{t1,x1},{t2,x2},…}, or TemporalData.
- The following forecast specifications can be given:
-
k at the k
step ahead{kmax} at 1, …, kmax steps ahead {kmin,kmax} at kmin, …, kmax steps ahead {{k1,k2,…}} use explicit {k1,k2,…} steps ahead - TimeSeriesForecast returns the forecasted value if k is an integer and TemporalData otherwise.
- The default for k is 1.
- TimeSeriesForecast supports a Method option with the following settings:
-
Automatic automatically determine the method "AR" approximate with a large-order AR process "Covariance" exact covariance function-based "Kalman" use Kalman filter - The mean squared errors of the prediction are the compounded noise errors and are given as MetaInformation in the TemporalData output. For forecast=TimeSeriesForecast[tproc,data,k], the mean squared errors can be accessed by forecast["MeanSquaredErrors"].
Examples
open all close allBasic Examples (3)
Forecast three steps ahead for an ARProcess:
data = {.1, .3, -.2, 0, -.2, .2};TimeSeriesForecast[ARProcess[{-.2, .4, .6}, .1], data, 3]An ARMAProcess:
TimeSeriesForecast[ARMAProcess[{.2, -.1}, {-.2, .3}, .1], data, 3]Predict the seventh value from TimeSeriesModel:
data = RandomFunction[ARMAProcess[{.2, -.1}, {-.2, .3}, .1], {10 ^ 3}];
tsmod = TimeSeriesModelFit[data, "ARMA"];forecast = TimeSeriesForecast[tsmod, 7]Mean squared error of the forecast:
TimeSeriesForecast[tsmod, {{7}}]["MeanSquaredErrors"]["Path"]Forecast a vector-valued time series process:
proc = ARMAProcess[{{{.8, .2}, {.3, .1}}}, {{{.2, 1}, {.5, -.3}}}, {{1, .2}, {.2, .5}}];
SeedRandom[3];
data = RandomFunction[proc, {0, 15}];Find the forecast for the next 10 steps:
forecast = TimeSeriesForecast[proc, data, {10}]Plot the data and the forecast for each component:
Row@Table[ListLinePlot[#["PathComponent", j]& /@ {data, forecast}, PlotLabel -> Subscript[x, j], PlotLegends -> {"data", "forecast"}], {j, 1, 2}]Scope (7)
Step (4)
data = {.2, .4, -.1};
proc = ARProcess[1, {.4}, 1];TimeSeriesForecast[proc, data]Forecast the third step ahead:
TimeSeriesForecast[proc, data, 3]Find forecast for all the steps ahead up to the fifth:
data = {.2, .4, -.1};
proc = ARProcess[1, {.4}, 1];TimeSeriesForecast[proc, data, {5}]%["Path"]Forecast all the steps ahead in the range from third to fifth:
data = {.2, .4, -.1};
proc = ARProcess[1, {.4}, 1];TimeSeriesForecast[proc, data, {3, 5}]%["Path"]data = {.2, .4, -.1};
proc = ARProcess[1, {.4}, 1];TimeSeriesForecast[proc, data, {{2, 3, 5}}]%["Path"]Mean Squared Errors (3)
data = {.2, .4, -.1};
proc = ARProcess[1, {.4}, 1];TimeSeriesForecast[proc, data]Return the forecast as TemporalData to extract mean squared errors:
forecast = TimeSeriesForecast[proc, data, {{1}}]err = forecast["MeanSquaredErrors"]{forecast["Path"], err["Path"]}Find the forecast with mean squared errors:
proc = ARMAProcess[1.2, {.3, .2}, {.8}, .1];
data = RandomFunction[proc, {1, 20}];forecast = TimeSeriesForecast[proc, data, {0, 10}];err = Sqrt[forecast["MeanSquaredErrors"]];uband = TimeSeriesThread[{1, 1}.#&, {forecast, err}];lband = TimeSeriesThread[{1, -1}.#&, {forecast, err}];Plot the data and forecast with mean error bands:
ListLinePlot[{data, forecast, uband, lband}, PlotStyle -> {Automatic, Automatic, Gray, Gray}, Filling -> {3 -> {4}}]Find the forecast with 95% confidence intervals:
data = RandomFunction[proc = MAProcess[.4, {.3, .2}, .1], {1, 20}];Find the forecast for the next 10 steps:
forecast = TimeSeriesForecast[ARMAProcess[{-.2, .4, .6}, {.2, .1}, .1], data, {0, 10}];Find mean squared errors and confidence intervals:
err = Sqrt[forecast["MeanSquaredErrors"]];
quantile = Quantile[NormalDistribution[], 1 - 1 / 2 (1 - .95)];uband = TimeSeriesThread[{1, quantile}.#&, {forecast, err}];lband = TimeSeriesThread[{1, -quantile}.#&, {forecast, err}];Plot data, forecast, and the forecast limits:
ListLinePlot[{data, forecast, uband, lband}, PlotStyle -> {Automatic, Automatic, Gray, Gray}, Filling -> {3 -> {4}}]Options (4)
Method (4)
Find the forecast using the covariance-based method:
proc = MAProcess[{.3, .4}, 1];
data = {1, 1.4, 2};
forecast = TimeSeriesForecast[proc, data, {6}, Method -> "Covariance"]forecast["Path"]Find the forecast using the autoregressive method:
proc = MAProcess[{.3, .4}, 1];
data = {1, 1.4, 2};
forecast = TimeSeriesForecast[proc, data, {6}, Method -> "AR"]forecast["Path"]Find the forecast using the Kalman filter method:
proc = MAProcess[{.3, .4}, 1];
data = {1, 1.4, 2};
forecast = TimeSeriesForecast[proc, data, {6}, Method -> "Kalman"]forecast["Path"]Compare exact and approximate methods for an MAProcess:
ma = MAProcess[{a}, σ^2];TimeSeriesForecast[ma, Array[x, 3], Method -> "Covariance"]TimeSeriesForecast[ma, Array[x, 3], Method -> "AR"]Both methods agree for the autoregressive processes:
ar = ARProcess[{a}, σ ^ 2];TimeSeriesForecast[ar, Array[x, 3], Method -> "Covariance"]TimeSeriesForecast[ar, Array[x, 3], Method -> "AR"]Applications (3)
The daily exchange rates of the euro to the dollar from May 2012 through September 2012:
data = TemporalData[Automatic, {{{1.31, 1.31, 1.31, 1.3, 1.3, 1.3, 1.29, 1.29, 1.29, 1.27, 1.28, 1.28,
1.27, 1.26, 1.26, 1.26, 1.25, 1.24, 1.24, 1.23, 1.24, 1.24, 1.25, 1.26, 1.25, 1.26, 1.25, 1.25,
1.26, 1.26, 1.26, 1.26, 1.27, 1.27, 1.25, 1.25 ... Data`DateSpecification[{2012, 5, 2}, {2012, 9, 28}, "BusinessDay", "DayRange"]}, 1,
{"Discrete", 1}, {"Discrete", 1}, 1,
{MetaInformation -> {"Source" -> HoldForm[FinancialData]["EUR/USD",
{{2012, 5, 1}, {2012, 9, 30}}]}}}, True, 9.];data["Source"]DateListPlot[data, Joined -> True, Filling -> Bottom]Fit an AR process to the exchange rates:
eproc = EstimatedProcess[data, ARProcess[3]]Forecast for 20 business days ahead:
forecast = TimeSeriesForecast[eproc, data, {20}]Plot the forecast with original data:
DateListPlot[{data, forecast}, Joined -> True, Filling -> Bottom]Consider hourly temperature readings for September 9, 2012, near your location:
data = WeatherData[First@FindGeoLocation[], "Temperature", {2012, 9, 9}]The data contains missing values:
FreeQ[data, Missing]Redefine time series with MissingDataMethod to fill in missing data with interpolated values:
data1 = TimeSeries[data, MissingDataMethod -> {"Interpolation", InterpolationOrder -> 1}]Check if the time stamps are regularly spaced:
RegularlySampledQ[data1]temp = TimeSeriesResample[data1, "Hour"]RegularlySampledQ[temp]Estimate an ARProcess:
proc = EstimatedProcess[temp, ARProcess[3]]Calculate prediction for the next 12 hours:
forecast = TimeSeriesForecast[proc, temp, {12}]Plot forecast with original data:
DateListPlot[{temp, forecast}, Filling -> Axis, Joined -> True]Retail monthly sales in United States:
raw = WolframAlpha["usa retail sales", {{"History:RetailSales:EconomicData", 1}, "TimeSeriesData"}];raw[[1]]Create TimeSeries from the selection:
data = QuantityMagnitude[TimeSeries[raw[[-12 * 15 ;; , 2]], {Automatic, raw[[-1, 1]], "Month"}]]Plot the sales with grid lines at December peaks:
grids = Table[{1992, 12 i}, {i, data["PathLength"]}];
DateListPlot[data, GridLines -> {grids, None}, AspectRatio -> 1 / 3]model = TimeSeriesModelFit[data, {"SARIMA", 12}]proc = model["BestFit"]Properties & Relations (3)
Forecasting with ARProcess using the exact or approximate method gives the same result:
TimeSeriesForecast[ARProcess[{a}, σ^2], {x, y, z}, {5}, Method -> "Covariance"]["Path"]TimeSeriesForecast[ARProcess[{a}, σ^2], {x, y, z}, {5}, Method -> "AR"]["Path"]% - %%Forecast is the same for a time series process and its invertible representation:
proc = MAProcess[{3., 1.}, 1];This process is not invertible:
TimeSeriesInvertibility[proc]Find its invertible representation:
invproc = ToInvertibleTimeSeries[proc]data = {.2, -.3, .4};forecast = TimeSeriesForecast[proc, data, {3}]invforecast = TimeSeriesForecast[invproc, data, {3}]forecast - invforecast%["Path"]Use TimeSeriesModel to forecast:
data = TemporalData[TimeSeries,
{{{Quantity[46.76, "DegreesFahrenheit"], Quantity[50., "DegreesFahrenheit"],
Quantity[68.31, "DegreesFahrenheit"], Quantity[72.84, "DegreesFahrenheit"],
Quantity[71.74, "DegreesFahrenheit"], Quantity[76.75, "Deg ... DegreesFahrenheit"]}}, {TemporalData`DateSpecification[{2007, 3, 1, 0, 0, 0.},
{2017, 3, 1, 0, 0, 0}, {1, "Month"}]}, 1, {"Continuous", 1}, {"Discrete", 1}, 1,
{ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, True, 314.1];tsm = TimeSeriesModelFit[data]Compute forecast for 20 steps:
forecast = TimeSeriesForecast[tsm, {20}]Use process and data explicitly:
res = TimeSeriesForecast[tsm["Process"], tsm["TemporalData"], {20}]forecast["Path"] == res["Path"]Possible Issues (2)
"Kalman" method requires the parameters of the process to be numeric:
TimeSeriesForecast[ARProcess[{a}, σ^2], {x, y, z}, 6, Method -> "Kalman"]If the invertible representation does not exist, the forecast may not be reliable:
ft = TimeSeriesForecast[MAProcess[{1}, 1], {1, 2, 3}, {3}, Method -> "AR"]ft["Path"]Related Guides
Text
Wolfram Research (2012), TimeSeriesForecast, Wolfram Language function, https://reference.wolfram.com/language/ref/TimeSeriesForecast.html (updated 2014).
CMS
Wolfram Language. 2012. "TimeSeriesForecast." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/TimeSeriesForecast.html.
APA
Wolfram Language. (2012). TimeSeriesForecast. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TimeSeriesForecast.html
BibTeX
@misc{reference.wolfram_2026_timeseriesforecast, author="Wolfram Research", title="{TimeSeriesForecast}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/TimeSeriesForecast.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_timeseriesforecast, organization={Wolfram Research}, title={TimeSeriesForecast}, year={2014}, url={https://reference.wolfram.com/language/ref/TimeSeriesForecast.html}, note=[Accessed: 12-June-2026]}