naginterfaces.library.tsa.multi_filter_arima¶
- naginterfaces.library.tsa.multi_filter_arima(y, mr, par, cy=None)[source]¶
multi_filter_arima
filters a time series by an ARIMA model.For full information please refer to the NAG Library document for g13ba
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g13/g13baf.html
- Parameters
- yfloat, array-like, shape
The backforecasts, starting with backforecast at time to backforecast at time , followed by the time series starting at time , where . If there are no backforecasts, either because the ARIMA model for the time series is not known, or because it is known but has no moving average terms, then the time series starts at the beginning of .
- mrint, array-like, shape
The orders vector for the filtering model, followed by the orders vector for the ARIMA model for the time series if the latter is known. The orders appear in the standard sequence as given in the G13 Introduction. If the ARIMA model for the time series is supplied, the function will assume that the first values of the array are backforecasts.
- parfloat, array-like, shape
The parameters of the filtering model, followed by the parameters of the ARIMA model for the time series, if supplied. Within each model the parameters are in the standard order of non-seasonal AR and MA followed by seasonal AR and MA.
- cyNone or float, optional
If the ARIMA model is known (i.e., ), must specify the constant term of the ARIMA model for the time series. If this model is not known (i.e., ), is not used.
- Returns
- bfloat, ndarray, shape
The filtered output series. If the ARIMA model for the time series was known, and hence backforecasts were supplied in , then contains ‘filtered’ backforecasts followed by the filtered series. Otherwise, the filtered series begins at the start of just as the original series began at the start of . In either case, if the value of the series at time is held in , then the filtered value at time is held in .
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, the orders vector is invalid.
- (errno )
On entry, .
Constraint: must be inconsistent with .
- (errno )
On entry, and the minimum size .
Constraint: .
- (errno )
The orders vector for the filtering model is invalid.
- (errno )
The orders vector for the ARIMA model is invalid.
- (errno )
The initial values of the filtered series are indeterminate for the given models.
- Notes
From a given series , a new series is calculated using a supplied (filtering) ARIMA model. This model will be one which has previously been fitted to a series with residuals . The equations defining in terms of are very similar to those by which is obtained from . The only dissimilarity is that no constant correction is applied after differencing. This is because the series is generally distinct from the series with which the model is associated, though may be related to . Whilst it is appropriate to apply the ARIMA model to so as to preserve the same relationship between and as exists between and , the constant term in the ARIMA model is inappropriate for . The consequence is that will not necessarily have zero mean.
The equations are precisely:
the appropriate differencing of ; both the seasonal and non-seasonal inverted autoregressive operations are then applied,
followed by the inverted moving average operations
Because the filtered series value depends on present and past values , there is a problem arising from ignorance of which particularly affects calculation of the early values , causing ‘transient errors’. The function allows two possibilities.
The equations (1), (2) and (3) are applied from successively later time points so that all terms on their right-hand sides are known, with being defined for . Equations (4) and (5) are then applied over the same range, taking any values on the right-hand side associated with previous time points to be zero.
This procedure may still however result in unacceptably large transient errors in early values of .
The unknown values are estimated by backforecasting. This requires that an ARIMA model distinct from that which has been supplied for filtering, should have been previously fitted to .
For efficiency, you are asked to supply both this ARIMA model for and a limited number of backforecasts which are prefixed to the known values of . Within the function further backforecasts of , and the series , , in (1), (2) and (3) are then easily calculated, and a set of linear equations solved for backforecasts of for use in (4) and (5) in the case that .
Even if the best model for is not available, a very approximate guess such as
or
can help to reduce the transients substantially.
The backforecasts which need to be prefixed to are of length , where and are the non-seasonal and seasonal moving average orders and the seasonal period for the ARIMA model of . Thus you need not carry out the backforecasting exercise if . Otherwise, the series should be reversed to obtain and
uni_arima_forcecast()
should be used to forecast values, . The ARIMA model used is that fitted to (as a forward series) except that, if is odd, the constant should be changed in sign (to allow, for example, for the fact that a forward upward trend is a reversed downward trend). The ARIMA model for supplied to the filtering function must however have the appropriate constant for the forward series.The series is then supplied to the function, and a corresponding set of values returned for .
- References
Box, G E P and Jenkins, G M, 1976, Time Series Analysis: Forecasting and Control, (Revised Edition), Holden–Day