pyhctsa.operations.model_fit.steps_ahead¶
-
pyhctsa.operations.model_fit.steps_ahead(y, model=
'ar', order=2, max_steps=6)¶ How the accuracy of multi-step-ahead model predictions compares with trivial predictors and changes with the horizon.
Given a model, characterizes the variation in goodness of model predictions across a range of prediction lengths,
l, from 1-step-ahead tomax_steps-steps-ahead predictions. The model is fitted on the full time series and then used to predict the same data (so all predictions are within the sample).At each horizon, the errors of the model are compared with those of three trivial predictors: (i) the value
lsamples earlier (a sliding mean of length 1), (ii) the average of the last two values, iterated forwardlsteps (a sliding mean of length 2), and (iii) the mean of the full time series.- Parameters:¶
- y : array-like¶
The input time series.
- model : {'ar', 'arma', 'ss'}, optional¶
The time-series model to fit: an AR model (forward-backward least squares), an ARMA model (prediction-error minimization), or a state-space model (subspace N4SID). Default is
'ar'. The predictions of the fitted model start from a diffuse initial state (_prediction_errors()); the first samples, which determine it, are not predicted.- order : int, 'best' or two-vector, optional¶
The order of the model to fit: an integer for
'ar'and'ss', a two-vector[p, q]for'arma', or'best'. For'ar','best'picks the order (1 to 10) by Schwarz’s Bayesian criterion using ARfit; for'ss', the order from 1 to 10 is chosen by Akaike’s information criterion. Default is 2.- max_steps : int, optional¶
The maximum number of steps ahead to predict. Default is 6.
- Returns:¶
stde_h1, …,stde_h<max_steps>: the root-mean-square error of the model at horizonl, divided by the lowest root-mean-square error of the three trivial predictors at that horizon,meanabs_h1, …: the same for the mean absolute error,ac1_h1, …: the absolute lag-1 autocorrelation of the model’s errors at each horizon (not a ratio; NaN if the errors do not vary beyond the level of rounding: their standard deviation is at most 1e-9 times the larger of that of the series and their mean absolute value,_is_rounding_level()),stde_meanabs_diff: the absolute value of the mean difference between the model’s root-mean-square and mean absolute errors across horizons,stde_meandiff,stde_maxdiff,stde_stddiff: the mean, maximum, and standard deviation of the change in the model’s root-mean-square error from one horizon to the next,stde_ndown: the number of horizon steps at which the model’s root-mean-square error falls.
The last five outputs use the model’s raw errors, not the ratios to the trivial predictors. NaN if the model cannot be fitted.
- Return type:¶
dict