library.tsa
Submodule¶
Module Summary¶
Interfaces for the NAG Mark 30.3 tsa Chapter.
tsa
- Time Series Analysis
This module provides facilities for investigating and modelling the statistical structure of series of observations collected at points in time. The models may then be used to forecast the series.
The module covers the following models and approaches:
univariate time series analysis, including autocorrelation functions and autoregressive moving average (ARMA) models;
univariate spectral analysis;
transfer function (multi-input) modelling, in which one time series is dependent on other time series;
bivariate spectral methods including coherency, gain and input response functions;
vector ARMA models for multivariate time series;
Kalman filter models (linear and nonlinear);
GARCH models for volatility;
inhomogeneous time series.
See Also¶
naginterfaces.library.examples.tsa
:This subpackage contains examples for the
tsa
module. See also the Examples subsection.
Functionality Index¶
ARMA modelling
ACF:
uni_autocorr()
diagnostic checking:
uni_arima_resid()
Dickey–Fuller unit root test:
uni_dickey_fuller_unit()
differencing:
uni_diff()
estimation (comprehensive):
uni_arima_estim()
estimation (easy-to-use):
uni_arima_estim_easy()
forecasting from fully specified model:
uni_arima_forcecast()
forecasting from state set:
uni_arima_forecast_state()
mean/range:
uni_means()
PACF:
uni_autocorr_part()
preliminary estimation:
uni_arima_prelim()
update state set:
uni_arima_update()
Change point
detection
binary segmentation:
cp_binary()
PELT:
cp_pelt()
Exponential smoothing: uni_smooth_exp()
GARCH
EGARCH
fitting:
uni_garch_exp_estim()
forecasting:
uni_garch_exp_forecast()
GJR GARCH
fitting:
uni_garch_gjr_estim()
forecasting:
uni_garch_gjr_forecast()
symmetric or type I AGARCH
fitting:
uni_garch_asym1_estim()
forecasting:
uni_garch_asym1_forecast()
type II AGARCH
fitting:
uni_garch_asym2_estim()
forecasting:
uni_garch_asym2_forecast()
Inhomogeneous series
iterated exponential moving average
final value only returned:
inhom_iema()
intermediate values returned:
inhom_iema_all()
moving average:
inhom_ma()
Kalman
filter
time invariant
square root covariance:
multi_kalman_sqrt_invar()
time varying
square root covariance:
multi_kalman_sqrt_var()
unscented:
kalman_unscented_state()
unscented (reverse communication):
kalman_unscented_state_revcom()
Spectral analysis
Bivariate
Bartlett, Tukey, Parzen windows:
multi_spectrum_lag()
cross amplitude spectrum:
multi_spectrum_bivar()
direct smoothing:
multi_spectrum_daniell()
gain and phase:
multi_gain_bivar()
noise spectrum:
multi_noise_bivar()
Univariate
Bartlett, Tukey, Parzen windows:
uni_spectrum_lag()
direct smoothing:
uni_spectrum_daniell()
Transfer function modelling
cross-correlations:
multi_xcorr()
filtering:
multi_filter_transf()
fitting:
multi_inputmod_estim()
forecasting from fully specified model:
multi_inputmod_forecast()
forecasting from state set:
multi_inputmod_forecast_state()
preliminary estimation:
multi_transf_prelim()
pre-whitening:
multi_filter_arima()
update state set:
multi_inputmod_update()
Vector ARMA
cross-correlations:
multi_corrmat_cross()
diagnostic checks:
multi_varma_diag()
differencing:
multi_diff()
fitting:
multi_varma_estimate()
forecasting:
multi_varma_forecast()
partial autoregression matrices:
multi_regmat_partial()
partial correlation matrices:
multi_corrmat_partlag()
squared partial autocorrelations:
multi_autocorr_part()
update forecast:
multi_varma_update()
zeros of ARIMA operator:
uni_arma_roots()
For full information please refer to the NAG Library document
https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/g13/g13intro.html
Examples¶
- naginterfaces.library.examples.tsa.cp_pelt_ex.main()[source]¶
Example for
naginterfaces.library.tsa.cp_pelt()
.Change point detection, using the PELT algorithm.
>>> main() naginterfaces.library.tsa.cp_pelt Python Example Results. Change point detection, using the PELT algorithm. -- Change Points -- --- Distribution --- Number Positions Parameters 1 12 0.34 1.00 2 32 2.57 1.00 3 49 1.45 1.00 4 52 -0.48 1.00 5 70 1.20 1.00 6 100 -0.23 1.00
- naginterfaces.library.examples.tsa.inhom_iema_ex.main()[source]¶
Example for
naginterfaces.library.tsa.inhom_iema()
.Iterated exponential moving average for a univariate inhomogeneous time series.
>>> main() naginterfaces.library.tsa.inhom_iema Python Example Results. IEMA for an inhomogeneous time series. Time IEMA ______________ 7.500 0.531 8.200 0.544 18.100 0.754 22.800 0.406 25.800 0.232 26.800 0.217 31.100 0.357 38.400 0.630 45.900 0.263 48.200 0.241 48.900 0.279 57.900 0.713 58.500 0.717 63.900 0.385 65.200 0.346 66.600 0.330 67.400 0.315 69.300 0.409 69.900 0.459 73.000 0.377 75.600 0.411 77.000 0.536 84.700 0.632 86.800 0.538 88.000 0.444 88.500 0.401 91.000 0.331 93.000 0.495 93.700 0.585 94.000 0.612
- naginterfaces.library.examples.tsa.kalman_unscented_state_ex.main()[source]¶
Example for
naginterfaces.library.tsa.kalman_unscented_state()
.Combined time and measurement update, one iteration of the Unscented Kalman Filter for a nonlinear state space model, with additive noise.
Demonstrates passing user-defined communication data to callback functions.
>>> main() naginterfaces.library.tsa.kalman_unscented_state Python Example Results. Applying the UKF to a nonlinear state space model, with additive noise. At time point 0, state estimate is: ( 0.664, -0.092, 0.104) At time point 1, state estimate is: ( 1.598, 0.081, 0.314) At time point 2, state estimate is: ( 2.128, 0.213, 0.378) At time point 3, state estimate is: ( 3.134, 0.674, 0.660) At time point 4, state estimate is: ( 3.809, 1.181, 0.906) At time point 5, state estimate is: ( 4.730, 2.000, 1.298) At time point 6, state estimate is: ( 4.429, 2.474, 1.762) At time point 7, state estimate is: ( 4.357, 3.246, 2.162) At time point 8, state estimate is: ( 3.907, 3.852, 2.246) At time point 9, state estimate is: ( 3.360, 4.398, 2.504) At time point 10, state estimate is: ( 2.552, 4.741, 2.750) At time point 11, state estimate is: ( 2.191, 5.193, 3.281) At time point 12, state estimate is: ( 1.309, 5.018, 3.610) At time point 13, state estimate is: ( 1.071, 4.894, 4.031) At time point 14, state estimate is: ( 0.618, 4.322, 4.124) Estimate of the Cholesky factorization of the state covariance matrix at the last time point: [ 1.92e-01 -3.82e-01, 2.22e-02 1.58e-06, 2.23e-07, 9.95e-03 ]
- naginterfaces.library.examples.tsa.multi_inputmod_ex.main()[source]¶
Example for
naginterfaces.library.tsa.multi_inputmod_estim()
andnaginterfaces.library.tsa.multi_inputmod_forecast_state()
.Multivariate time series: estimation of multi-input model and forecasting.
>>> main() naginterfaces.library.tsa.multi_inputmod Python Example Results. Multivariate time series: estimate and forecast. Begin estimation. Begin forecasting. The forecast values and their standard errors: No. Value Std error 1 97.306 4.788 2 101.785 6.328 3 103.812 7.145 4 102.073 7.360 Forecast components z(t): Series No.: 1: [175.413, 177.712, 179.373, 178.372] Output noise n(t): [-78.10695358 -75.92741605 -75.56034026 -76.29929963]
- naginterfaces.library.examples.tsa.uni_dickey_fuller_unit_ex.main()[source]¶
Example for
naginterfaces.library.tsa.uni_dickey_fuller_unit()
.(Augmented) Dickey–Fuller unit root test statistic.
>>> main() naginterfaces.library.tsa.uni_dickey_fuller_unit Python Example Results. Dickey--Fuller unit root test. Dickey--Fuller test statistic = -2.538
- naginterfaces.library.examples.tsa.uni_garch_asym1_ex.main()[source]¶
Example for
naginterfaces.library.tsa.uni_garch_asym1()
.Type-I AGARCH parameter estimation and forecasting.
>>> main() naginterfaces.library.tsa.uni_garch_asym1 Python Example Results. Fit a GARCH(1,1) model with Student's t-distributed residuals. Parameter Standard estimates errors alpha_0 0.00 0.06 alpha_1 0.11 0.13 beta_1 0.66 0.23 gamma -0.62 0.62 df 6.25 4.70 b_0 3.85 24.11 b_1 1.48 1.82 b_2 2.15 10.16 Volatility forecast = 0.09