arch.univariate.HARX.forecast¶

HARX.forecast(params: ndarray  Series, horizon: int =
1
, start: int  str  datetime  datetime64  Timestamp  None =None
, align: 'origin'  'target' ='origin'
, method: 'analytic'  'simulation'  'bootstrap' ='analytic'
, simulations: int =1000
, rng: Callable[[int  tuple[int, ...]], ndarray[Any, dtype[float64]]]  None =None
, random_state: RandomState  None =None
, *, reindex: bool =False
, x: dict[Hashable  None, ndarray  DataFrame  Series]  ndarray  DataFrame  Series  None =None
) ARCHModelForecast [source]¶ Construct forecasts from estimated model
 Parameters:¶
 params: ndarray  Series¶
Parameters required to forecast. Must be identical in shape to the parameters computed by fitting the model.
 horizon: int =
1
¶ Number of steps to forecast
 start: int  str  datetime  datetime64  Timestamp  None =
None
¶ 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: 'origin'  'target' =
'origin'
¶ 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' =
'analytic'
¶ 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 =
1000
¶ Number of simulations to run when computing the forecast using either simulation or bootstrap.
 rng: Callable[[int  tuple[int, ...]], ndarray[Any, dtype[float64]]]  None =
None
¶ 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  None =
None
¶ NumPy RandomState instance to use when method is ‘bootstrap’
 reindex: bool =
False
¶ 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.
Added in version 4.19.
 x: dict[Hashable  None, ndarray  DataFrame  Series]  ndarray  DataFrame  Series  None =
None
¶ 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, horizon) 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. When using an (nobs, horizon) array, the values much be aligned so that all values in row t are all outofsample at timet.
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 passed 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, and discusses alignment.
Added in version 4.19.
 Returns:¶
Container for forecasts. Key properties are
mean
,variance
andresidual_variance
. Return type:¶
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()
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.