arch.univariate.ARX.forecast¶

ARX.
forecast
(params, horizon=1, start=None, align='origin', method='analytic', simulations=1000, rng=None, random_state=None, *, reindex=None, x=None)¶ Construct forecasts from estimated model
 Parameters
 params{
ndarray
,Series
},optional
Alternative parameters to use. If not provided, the parameters estimated when fitting the model are used. Must be identical in shape to the parameters computed by fitting the model.
 horizon
int
,optional
Number of steps to forecast
 start{
int
,datetime
,Timestamp
,str
},optional
An integer, datetime or str indicating the first observation to produce the forecast for. Datetimes can only be used with pandas inputs that have a datetime index. Strings must be convertible to a date time, such as in ‘19450101’.
 align
str
,optional
Either ‘origin’ or ‘target’. When set of ‘origin’, the tth row of forecasts contains the forecasts for t+1, t+2, …, t+h. When set to ‘target’, the tth row contains the 1step ahead forecast from time t1, the 2 step from time t2, …, and the hstep from time th. ‘target’ simplified computing forecast errors since the realization and hstep forecast are aligned.
 method{‘analytic’, ‘simulation’, ‘bootstrap’}
Method to use when producing the forecast. The default is analytic. The method only affects the variance forecast generation. Not all volatility models support all methods. In particular, volatility models that do not evolve in squares such as EGARCH or TARCH do not support the ‘analytic’ method for horizons > 1.
 simulations
int
Number of simulations to run when computing the forecast using either simulation or bootstrap.
 rng
callable()
,optional
Custom random number generator to use in simulationbased forecasts. Must produce random samples using the syntax rng(size) where size the 2element tuple (simulations, horizon).
 random_state
RandomState
,optional
NumPy RandomState instance to use when method is ‘bootstrap’
 reindexbool,
optional
Whether to reindex the forecasts to have the same dimension as the series being forecast. Prior to 4.18 this was the default. As of 4.19 this is now optional. If not provided, a warning is raised about the future change in the default which will occur after September 2021.
New in version 4.19.
 x{
dict
[label
, numpy:array_like], numpy:array_like} Values to use for exogenous regressors if any are included in the model. Three formats are accepted:
2d arraylike: This format can be used when there is a single exogenous variable. The input must have shape (nforecast, horizon) or (nobs, horzion) where nforecast is the number of forecasting periods and nobs is the original shape of y. For example, if a single series of forecasts are made from the end of the sample with a horizon of 10, then the input can be (1, 10). Alternatively, if the original data had 1000 observations, then the input can be (1000, 10), and only the final row is used to produce forecasts.
A dictionary of 2d arraylike: This format is identical to the previous except that the dictionary keys must match the names of the exog variables. Requires that the exog variables were pass as a pandas DataFrame.
A 3d NumPy array (or equivalent). In this format, each panel (0th axis) is a 2d array that must have shape (nforecast, horizon) or (nobs,horizon). The array x[j] corresponds to the jth column of the exogenous variables.
Due to the complexity required to accommodate all scenarios, please see the example notebook that demonstrates the valid formats for x.
New in version 4.19.
 params{
 Returns
arch.univariate.base.ARCHModelForecast
Container for forecasts. Key properties are
mean
,variance
andresidual_variance
.
Notes
The most basic 1step ahead forecast will return a vector with the same length as the original data, where the tth value will be the timet forecast for time t + 1. When the horizon is > 1, and when using the default value for align, the forecast value in position [t, h] is the timet, h+1 step ahead forecast.
If model contains exogenous variables (model.x is not None), then only 1step ahead forecasts are available. Using horizon > 1 will produce a warning and all columns, except the first, will be nanfilled.
If align is ‘origin’, forecast[t,h] contains the forecast made using y[:t] (that is, up to but not including t) for horizon h + 1. For example, y[100,2] contains the 3step ahead forecast using the first 100 data points, which will correspond to the realization y[100 + 2]. If align is ‘target’, then the same forecast is in location [102, 2], so that it is aligned with the observation to use when evaluating, but still in the same column.
Examples
>>> import pandas as pd >>> from arch import arch_model >>> am = arch_model(None,mean='HAR',lags=[1,5,22],vol='Constant') >>> sim_data = am.simulate([0.1,0.4,0.3,0.2,1.0], 250) >>> sim_data.index = pd.date_range('20000101',periods=250) >>> am = arch_model(sim_data['data'],mean='HAR',lags=[1,5,22], vol='Constant') >>> res = am.fit() >>> fig = res.hedgehog_plot()
 Return type