Python self-excitation threshold autoregression (SETAR), ARMA, BDS test, predictive analysis of sunspot time series data…

Full text link: https://tecdat.cn/?p=33896

This article demonstrates the use of self-excitation threshold autoregressive SETAR for the analysis of sunspot data sets frequently studied by customers. Specifically, study the estimation and prediction of the SETAR model(Click “Read the original text” at the end of the article to obtain the completecode data< /strong>).

Related videos

We consider here raw sunspot sequences to fit ARMA examples, although many sources in the literature transform the sequences before modeling.

import numpy as np
import pandas as pd
......
dta.index = pd.Index(sm.....m_range('1700', '2008'))

d52c465dc0f2402bc2eaecd52c6ae074.png

Click on the title to view previous issues

23c844e8b969d8d7c66b44075e507a9c.jpeg

R language time series TAR threshold autoregressive model

outside_default.png

Swipe left or right to see more

outside_default.png

01

afb58f0e942923c16b701522c177e53d.png

02

f5f6d7af9b55da0416f5b6fca7a9b099.png

03

13e731dc5e5bdcc6e4eb3434202c5989.png

04

c5e4f2033344a9f8e0b9d6af7d74d122.png

First, we will use ARMA to fit the AR(3) process to the data.

arma_mod30 = sm.tsa.ARMA(dta, (3,0)).fit()......0.hqic

8b76e5f9f3eb56b70312256f8da952b6.png

To test for nonlinearity, a BDS test can be performed using the residuals of a linear AR(3) model.

bds.bds(arm......sid, 3)

1fa61294a95c3eda9d472eef33937270.png

This suggests that there may be an underlying nonlinear structure. To try to capture this structure, we will fit a SETAR(2) model to the data, allowing two regimes and each regime being an AR(3) process. Here, we do not specify delay or threshold values, so they will be optimally selected from the model.

Note: In the summary, the \gamma parameter is the threshold value.

ser_23 = star......).fit()

f84f73971d1c271c8529437ce94b483e.png

AIC and BIC guidelines prefer the SETAR model over the AR model.

Note: This is a bootstrap test, so it may be slow until it is improved.

f_sat, pae,bsf_tas = stoest()

3de1e604a3defa6ba2da1ec2298cc46f.png

The null hypothesis is SETAR(1), so we can reject it and choose SETAR(2) as the alternative hypothesis.

However, it should be noted that the default assumption of order_test() is the existence of heteroscedasticity, which may be unreasonable here.

f_stat_h, pvalue_h, bs_f_stats_h = ......g')
print pvalue

b534e953984168044ca6f7acb7c0e28f.png

It should be noted that when considering the time series residuals, the BDS test still rejects the null hypothesis, albeit to a smaller extent than the AR(3) model. We can look at the residual plot to see if the errors have zero mean, but may not have homoskedasticity.

print bds.bds(setar_mod23.resid, 3)
setar_mod23.resid.plot(figsize=(10,5));

56196685c0e798218281fe00b3ca528e.png

4e768dd89381eeab017f3d4a8ae9154e.png

Relative to the ARMA model, two new types of parameters are estimated here. Delay parameters and thresholds. The Lag parameter selects the process lag to use as the threshold variable, and Threshold indicates the threshold variable that separates the data points into (here two) states.

Alternative thresholds for which the likelihood ratio statistic is less than the critical value are included in the confidence set, and the lower and upper bounds of the confidence interval are the smallest and largest thresholds in the confidence set, respectively.

setarmd23.plo......ght=5);

a4d16b36eea89aa4b4cfaf25d074ec89.png

We can look at in-sample dynamic forecasts and out-of-sample forecasts.

predit_am_mo30 = arma_mod30.predict('1990', '2012', dynamic=True)
ax = dta.ix['1950':].pot(igsze=(12,8))......

3460ef690872c8c0da1f27b3f4ae3569.png

It appears that the dynamic predictions of the SETAR model are able to track the observed data points slightly better than the AR(3) model. We can compare by root mean square prediction error and see that SETAR performs slightly better.

def rsf(y, yhat):
    return (y.sb(yhat**2).man()
prnt 'AR(3): ', rse(dta.SNACTIVI......od23)

22da2e18d7da0edd34984a9fd40297e0.png

However, if the prediction window is expanded, it becomes apparent that the SETAR model is the only one that fits the shape of the data since the data is cyclic.

preict_am_mo30_long = ama_md30.predict('1960', '2012', dynamic=True)......
ax.legend();

3c1498f9059d4319fecbde85df8f677a.png

print 'AR(3): ', rmsfe(dta.S......ong)

260f8b167417e0861707fe058309466d.png

2e825eadcdd56ff2bc814c11fd982ae3.jpeg

Click “Read original text” at the end of the article

Get the full text and complete code data.

This article is selected from “Python Self-Excitation Threshold Autoregression (SETAR), ARMA, BDS Test, Predictive Analysis of Sunspot Time Series Data”.

72c2199e8a569f2a0bd892885e96910d.jpeg

eca08bc06bee9d1fce81877bc36fe135.png

Click on the title to view previous issues

Mathematical principles of vector autoregressive VAR and examples of economic data impulse response analysis using R software

[Video] Mathematical principles of vector autoregressive VAR and examples of impulse response analysis of economic data using R software

Iterative multivariate forecasting of vector autoregressive VAR estimates GDP growth rate time series | Data sharing

Quantile autoregressive QAR analysis of pain index: unemployment rate and inflation rate time series | data sharing

Time-varying Markov regional switching MRS autoregressive model analyzes economic time series

Vector Autoregressive (VAR) Model Analysis of Consumer Price Index (CPI) and Unemployment Rate Time Series

Matlab creates a vector autoregressive (VAR) model to analyze consumer price index (CPI) and unemployment rate time series

Stata generalized method of moments GMM panel vector autoregression VAR model selection, estimation, Granger causality test analysis of investment, income and consumption data

Time-varying vector autoregressive (TV-VAR) model analysis and visualization of time series in R language

R language uses vector autoregression (VAR) to conduct impulse response research and analysis of economic data

R language arima, vector autoregressive (VAR), periodic autoregressive (PAR) model to analyze temperature time series

Different types of impulse response analysis of VAR models in R language

R language stochastic search variable selection SSVS estimates Bayesian vector autoregressive (BVAR) models

R language time-varying parameter VAR stochastic model

Empirical research and analysis case of estimating time-varying VAR model time series using R language

R language vector autoregressive model (VAR) and its implementation

R language to implement vector autoregressive VAR model

Empirical research and analysis case of estimating time-varying VAR model time series using R language

Python and R use EWMA, ARIMA models to predict time series

R language uses LASSO, adaptive LASSO to predict inflation time series

ARIMA model, SARIMA model and SARIMAX model in Python for time series forecasting

R language arima, vector autoregressive (VAR), periodic autoregressive (PAR) model to analyze temperature time series

[Video] Python and R language use exponential weighted average (EWMA), ARIMA autoregressive moving average model to predict time series

dee472ec55465c2aa7892a0418bd98ff.png

6ad0d1c2fea98249c6cc46bedc7acf03.jpeg

48563743eaa00d37470ea4aa17c9be7b.png

The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge. Python entry skill treeHomepageOverview 381,658 people are learning the system