当前位置:网站首页>Mathematical modeling for war preparation 36 time series model 2
Mathematical modeling for war preparation 36 time series model 2
2022-06-30 16:41:00 【nuist__ NJUPT】
Catalog
One 、ARCH and GARCH Basic introduction of the model
This section focuses on the introduction ARCH Models and GARCH Model ( expand / The generalized ARCH Model ),ARCH Full name of the model “ Autoregressive conditional heteroscedasticity model ”, In modern high-frequency financial time series , Data are often characterized by volatility aggregation , But in the long run, the data is stable , That is, long-term variance, unconditional variance ) Is the fixed value , But in the short run, the variance is unstable , We call this heteroscedasticity conditional heteroscedasticity . Traditional time series models such as ARMA The model does not recognize this feature .ARCH The model was developed by the University of California Engel (Engle) professor 1982 In 《 Econometrics 》 The magazine (Econometrica) For the first time in a paper , Since then, it has developed rapidly in the field of econometrics , Professor Engel also 2003 Won the Nobel Prize in economics .
One 、ARCH and GARCH Basic introduction of the model
With ARIMA Equal time series model , Why introduce GARCH The model , Because for data showing volatility aggregation , It is stable in the long run , It is not stable in the short term , There is conditional heteroscedasticity , In this case , The traditional time series model can not be recognized , So it leads to ARCH Models and GARCH Model .
Let's look at the concept of conditional heteroscedasticity , The short term , Heteroscedasticity exists , We call it conditional heteroscedasticity , stay ARMA On the basis of the model, the ARCH Model , Generally considered ARCH All models are multiplicative conditional heteroscedasticity .
Let's see ARCH(1) Models and ARCH(q) Model , Time series have ARCH(1) Effects and time series have ARCH(q) effect , From the actual definition , It's easy to see ARCH The model is essentially right
t Modeling .
Let's see GARCH(p,q) Model , stay ARCH The model is extended on the basis of , Got it GARCH Model , We can see that we have joined ht Constraints .
Let's take a look at the inspection GARCH The method of effect , White noise test is required , If it's white noise , There is no GARCH effect , Cannot be used GARCH The model predicts , conversely , There is GARCH effect , have access to GARCH The model predicts . Of course, there is another LM Inspection is used to check whether there is GARCH effect , The details will be introduced later .
We need to know when to use ARCH Models and GARCH The model , In fact, when there is Heteroscedasticity in the perturbation term , Generally, you can observe by drawing a sequence diagram , See if there is a volatility data set .
Generally speaking , There are three strict statistical tests :
Method 1:LM test , Method 2:Q test , Method 3: Coefficient significance test .
Two 、 Classic case study
Let's look at a case of stock yield prediction , We have established ARMA Models and GARCH The model predicts .
First, use the original data to draw the time series diagram , It is obvious that the sequence is unstable , especially 2015 Year to 2016 The changes of the year are very drastic .
We need to calculate the daily yield , Describe and count the daily yield , At the same time, the time series diagram of daily yield is drawn , The details are as follows , It can be found that the daily yield is 0 Fluctuate around the value , The best yield on duty 5.86, Minimum rate of return -8.68, The average is still 0 near .
Next we need to test the yield series r Whether it is unit root , The test method is ADF test ( The null hypothesis : Is the unit root sequence , The alternative hypothesis : It's a stationary sequence ), You can find p Less than 0.05, Rejection of null hypothesis , Think that the sequence is stable , You can choose ARMA The model predicts .
We use stata Plot the correlation coefficient ACF And partial correlation coefficient PACF chart , As you can see from the diagram 3 Step sum 8 The correlation coefficient of order is significant , Then consider p and q Namely 3 and 8 The combination of , There are four options ARMA Model .
For the above four ARMA Model , We should AIC and BIC Value to compare the fitting effect of the model ,AIC and BIC The smaller the value of , It means that the fitting effect of the model is better , obvious model1 Of AIC and BIC The mean value is the smallest , choice model1.
Following pair ARMA(3,3) Model for parameter estimation , The resulting parameter values are as follows .
We get the predicted value of the residual and generate the histogram of the residual distribution , As shown below .
We need to check whether the residual is white noise ,P Greater than 0.05, The original hypothesis cannot be rejected , The residual is white noise , There is no obvious correlation between residuals , Therefore, it is considered that the effectiveness of the model is better .
Because you still need to use GARCH Model , So we need to do LM test : Check for the presence of GARCH error , There is GARCH effect , There is GARCH effect , To consider the use of GARCH Model , Otherwise, you can't use .LM Statistics are significantly different from 0 Of , Therefore, it is considered that ARCH error .
utilize AIC and BIX value , Choose the right one GARCH Model , Our choice is GARCH(1,1) Model , The details are as follows ,t Of the perturbation term under the distribution ARMA(3,3) Estimate .
We need to be right about GARCH Model for parameter estimation , The specific parameter estimates are as follows .
Last , Extend the time data 10 period , You can predict the data , The specific prediction results are as follows , It can be found that only the first four periods can be predicted , It will remain the same later .
Of the above prediction stata The code is as follows :
clear // Empty variables
* (1) Import data and generate time series (* and // Can be used to annotate a line )
insheet using "Bindex.csv" // Import... Located in the same folder as the code csv Data files
gen datevar = date(date,"YMD") // take csv The variables in the date Convert to stata Identifiable time data datevar
format datevar %td // Yes datevar The display format of , After conversion, use : The year of the sun and the moon Show
label variable datevar " date " // Set up datevar The label of is date , It is mainly used for the display of drawing
tsset datevar // Definition datevar Is a time series data
gen time=_n // Define a 1 To n Of time Sequence ,n Is the number of observations , The system automatically records in the background
tsset time // take time This sequence is defined as a time series , The following lag operators need to be used
// Deep painting B Refers to the time series diagram
line index datevar
graph export " Deep formation B Refers to the time series diagram .png", as(png) replace // Export pictures to local folder
// Calculate daily yield data
gen r=100*(index-L.index)/L.index //( Today's closing price - Yesterday's closing price )/ Yesterday's closing price L yes lag Abbreviation
// Day to day yield r Make descriptive statistics
summarize r
// Make a time series diagram of daily yield
line r datevar
graph export " Deep formation B Time series chart of daily yield .png", as(png) replace // Export pictures to local folder
// Test the yield series r Whether it is unit root , The test method is ADF test ( The null hypothesis : Is the unit root sequence , The alternative hypothesis : It's a stationary sequence )
dfuller r
// MacKinnon approximate p-value for Z(t) = 0.0000 p The value is 0 It means rejecting the original assumption , So we think r The sequence is stable
// Observe acf Graph and pacf chart , Judge AMRA The order of the model
ac r,lags(20) // Autocorrelation coefficient diagram , lagging 20 period
graph export " Autocorrelation coefficient diagram .png", as(png) replace // Export pictures to local folder
pac r,lags(20) // Partial autocorrelation coefficient diagram , lagging 20 period
graph export " Partial autocorrelation coefficient diagram .png", as(png) replace // Export pictures to local folder
// according to acf and pacf chart , The preliminary judgment uses four alternative ARMA Model to fit
set matsize 1500 // Set the maximum matrix size supported during calculation to a larger size , Otherwise, computers with poor computer performance may report errors in the calculation
arima r,arima(3,0,3) // use ARIMA(3,0,3) Model for r Estimate
estat ic // obtain AIC and BIC, Used to select the appropriate model ( The principle of small selection , See Lecture 11 for details )
arima r,arima(8,0,8)
estat ic
arima r,arima(3,0,8)
estat ic
arima r,arima(8,0,3)
estat ic
// ARIMA(3,0,3) Model AIC Values and BIC The average of the values is the smallest , So let's use this model to estimate
arima r,arima(3,0,3)
// The predicted value of residual error is obtained and the histogram of residual error distribution is generated
predict residess, residuals // Save residuals
hist residess,norm freq // norm freq Represents the probability density function plus the standard normal distribution
graph export " Residual distribution histogram .png", as(png) replace // Export pictures to local folder
// Check whether the residual is a white noise sequence , The test method is Q test : The original assumption is white noise , Alternative assumption is not white noise
wntestq residess, lag(12) // Carry out white noise test on the residual sequence
// Generate the square of the residuals , And carry on Q test
gen ressq = residess^2 // Generate square sequence of residuals ressq
wntestq ressq, lag(12) // For the square sequence of residuals ressq Conduct white noise test
// LM test : Whether there is ARCH error
reg ressq l.ressq l2.ressq l3.ressq l4.ressq l5.ressq // The square term of residual error is regressed to its lag term
gen LM_STAT=e(N)*e(r2) // Calculation LM statistic
display LM_STAT // Output LM statistic
display chiprob(e(df_m),LM_STAT) // Calculation p value
// utilize AIC BIC Select the appropriate model for estimation
// Be careful : The distribution of perturbation term in financial data often follows t Distribution
// Under normal distribution GARCH(1,1) It is estimated that
arch r,arima(3 0 3) arch(1) garch(1)
estat ic
// t Under distribution GARCH(1,1) It is estimated that
arch r,arima(3 0 3) arch(1) garch(1) distribution(t 3) // The degree of freedom is 3 Of t Distribution
estat ic
// Under normal distribution GARCH(2,2) It is estimated that
arch r,arima(3 0 3) arch(2) garch(2)
estat ic
// t Under distribution GARCH(2,2) It is estimated that
arch r,arima(3 0 3) arch(2) garch(2) distribution(t 3)
estat ic
// The fitting results are obtained , And make predictions
arch r,arima(3 0 3) arch(1) garch(1) distribution(t 3)
tsappend ,add(10) // Extend the time 10 period
predict result // Forecast the data
tsline result r, legend(label(1 " Predictive value ") label(2 " True value ")) // Draw fitting diagram
graph export " The prediction results are shown in the figure .png", as(png) replace // Export pictures to local folder 边栏推荐
- 2020蓝桥杯国赛B组-搬砖-(贪心排序+01背包)
- Which direction should college students choose to find jobs after graduation?
- mysql8报错:ERROR 1410 (42000): You are not allowed to create a user with GRANT解决办法
- Siyuan notes: can you provide shortcut keys for folding all titles on the page?
- 2022 Blue Bridge Cup group B - expense reimbursement - (linear dp| status DP)
- 云技能提升好伙伴,亚马逊云师兄今天正式营业
- Bc1.2 PD protocol
- Under the pressure of technology, you can quickly get started with eth smart contract development, which will take you into the ETH world
- 2022新消费半年盘点:行业遇冷,但这九个赛道依然吸金
- RT thread heap size setting
猜你喜欢

halcon知识:区域专题【07】

RT thread heap size Setting

RT thread heap size setting

Hundreds of lines of code to implement a JSON parser

Symantec electronic sprint technology innovation board: Tan Jian, the actual controller, is an American who plans to raise 620million yuan

Cesium-1.72 learning (add points, lines, cubes, etc.)

Cesium-1.72 learning (deploy offline resources)

JS ES5也可以创建常量?
![[bjdctf2020]the mystery of ip|[ciscn2019 southeast China division]web11|ssti injection](/img/c2/d6760826b81589781574aebff61f9a.png)
[bjdctf2020]the mystery of ip|[ciscn2019 southeast China division]web11|ssti injection

Rongsheng biology rushes to the scientific innovation board: it plans to raise 1.25 billion yuan, with an annual revenue of 260million yuan
随机推荐
MySQL master-slave configuration
flinkcdc如果监控的数据库为mongo就必须是集群版吗
快照和备份
Distributed machine learning: model average Ma and elastic average easgd (pyspark)
Installing jupyter notebook under Anaconda
容联云首发基于统信UOS的Rphone,打造国产化联络中心新生态
[machine learning] K-means clustering analysis
Mysql8 error: error 1410 (42000): you are not allowed to create a user with grant solution
'<', Hexadecimal value 0x3c, is an invalid problem solving
MicroBlaze serial port learning · 2
微信表情符号写入判决书,你发的OK、炸弹都可能成为“呈堂证供”
register_chrdev和cdev_init cdev_add用法区别
Mysql代理中间件Atlas安装和配置
Additional: (not written yet, don't look at ~ ~ ~) corsfilter filter;
Halcon knowledge: regional topics [07]
牛客网:乘积为正数的最长连续子数组
MySQL8.0开启远程连接权限的方法步骤
观测云与 TDengine 达成深度合作,优化企业上云体验
附加:(还没写,别看~~~)CorsFilter过滤器;
Unsupported major.minor version 52.0


t Modeling .















