pyhctsa.operations.model_fit.local_simple

pyhctsa.operations.model_fit.local_simple(y, forecast_meth='mean', train_length=3, tau=1)

Simple local time-series forecasting.

Simple predictors using the past train_length values of the time series to predict its next value. The residuals (prediction minus data) are summarized with the 'core' level of residual_analysis(), plus the Gaussianity of their distribution. The first train_length values are used for training only and are not forecast.

Parameters:
y : array-like

The input time series.

forecast_meth : str, optional

The forecasting method:

  • ’mean’: local mean prediction using the past train_length time-series values

  • ’median’: local median prediction using the past train_length time-series values

  • ’lfit’: local linear prediction using the past train_length time-series values

Default is 'mean'.

train_length : int or str, optional

The number of time-series values to use to forecast the next value, or a string that sets it from the series: ‘ac’ (the first zero crossing of the autocorrelation function of y, discrete), ‘ac1e’ (the floor of its first 1/e crossing) or ‘mi’ (the smaller of the first minimum of the Kraskov automutual information and the ‘ac1e’ delay), as in pyhctsa.utils.get_tau(). For ‘lfit’ with ‘ac’, ‘ac1e’ or ‘mi’, the window is at least 2 (a straight line needs two points). Default is 3.

tau : int or str, optional

The step, in samples: an integer, or a rule for get_tau() (e.g. 'ac1e'). The value at t is predicted from the train_length values at t - tau, t - 2 tau, ..., for every t, and the residuals’ serial-correlation statistics are taken at multiples of tau (residual_analysis(..., lag_unit=tau)). This is the forecast on the series sampled every tau samples, using all tau phases rather than one. Default 1. All outputs are NaN when a rule cannot set the delay.

Returns:

The 11 'core' residual statistics (meane, meanabs, stde, maxonstd, ac1, ac2, ac3, propbth, taurat, sws, swm) and normr2, the R-squared of a Gaussian fit to the kernel-smoothed distribution of the residuals. NaN if the series is too short to forecast or the window cannot be set.

Return type:

dict