金融数学应用硕士课程《金融事件序列分析》授课备课资料。采用R(3)
##
## Call:
## ar(x = dgnp, method = "mle")
##
## Coefficients:
## 1 2 3 4 5 6 7 8
## 0.4318 0.1985 -0.1180 0.0189 -0.1607 0.0900 0.0615 -0.0814
## 9
## 0.1940
##
## Order selected 9 sigma^2 estimated as 8.918e-05
AIC取9阶。
ADF的基础模型需要一个AR阶数,取\(p=9\)。 用fUnitRoots::adfTest()对GNP的对数值进行ADF单位根检验:
##
## Title:
## Augmented Dickey-Fuller Test
##
## Test Results:
## PARAMETER:
## Lag Order: 9
## STATISTIC:
## Dickey-Fuller: -1.8467
## P VALUE:
## 0.3691
##
## Description:
## Thu Apr 19 16:46:34 2018 by user: user
结果\(p\)值较大,说明不能拒绝零假设, 即对数GNP序列有单位根。
在fUnitRoots::adfTest()中, 用lag=指定检验所用AR的阶数, 用type="c"指定基础模型允许有一个非零常数项, 用type="nc"指定基础模型不允许有任何的常数项和线性项, 用type="ct"指定基础模型允许有常数项和线性项。
GNP对数序列的图形也像是有非随机线性增长趋势的情况。 为此,仍使用ADF检验,但是允许有非随机常数项和线性项:
## Warning in fUnitRoots::adfTest(gnp, lags = 9, type = "ct"): p-value greater
## than printed p-value
##
## Title:
## Augmented Dickey-Fuller Test
##
## Test Results:
## PARAMETER:
## Lag Order: 9
## STATISTIC:
## Dickey-Fuller: -0.0094
## P VALUE:
## 0.99
##
## Description:
## Thu Apr 19 16:46:34 2018 by user: user
结果仍是承认零假设, 认为有单位根存在。
尝试人为地拟合非随机线性增长趋势, 检验残差是否有单位根:
##
## Title:
## Augmented Dickey-Fuller Test
##
## Test Results:
## PARAMETER:
## Lag Order: 1
## STATISTIC:
## Dickey-Fuller: -0.0763
## P VALUE:
## 0.592
##
## Description:
## Thu Apr 19 16:46:34 2018 by user: user
结果说明用回归去掉非随机的线性增长趋势后仍有单位根存在。
使用tseries包的adf.test()执行单位根ADF检验:
## Warning in tseries::adf.test(gnp, k = 9): p-value greater than printed p-
## value
##
## Augmented Dickey-Fuller Test
##
## data: gnp
## Dickey-Fuller = -0.0093764, Lag order = 9, p-value = 0.99
## alternative hypothesis: stationary
tseries::adf.test()会去掉常数项和时间\(t\)的线性趋势, 然后以\(k\)阶的AR作为基础模型, 零假设是有单位根。
○○○○○
读入数据,从中计算日收盘价对数值序列及其一阶差分:
## An 'xts' object on 1950-01-03/2008-04-11 containing:
## Data: num [1:14662, 1:6] 16.7 16.9 16.9 17 17.1 ...
## - attr(*, "dimnames")=List of 2
## ..$ : NULL
## ..$ : chr [1:6] "open" "high" "low" "close" ...
## Indexed by objects of class: [Date] TZ: UTC
## xts Attributes:
## NULL
作日对数收盘价的时间序列图:
明显非平稳。一阶差分的时间序列图:
一阶差分的PACF:
用AIC对日对数收益率定阶:
##
## Call:
## ar(x = delta.sp5d, method = "mle")
##
## Coefficients:
## 1 2
## 0.0721 -0.0387
##
## Order selected 2 sigma^2 estimated as 8.068e-05
AIC定阶\(p=2\)。按\(p=2\)对标普500日对数收盘价作ADF白噪声检验:
##
## Title:
## Augmented Dickey-Fuller Test
##
## Test Results:
## PARAMETER:
## Lag Order: 2
## STATISTIC:
## Dickey-Fuller: -2.0179
## P VALUE:
## 0.5708
##
## Description:
## Thu Apr 19 16:46:42 2018 by user: user
检验不显著,说明存在单位根。 如果对日对数收益率(即对数收盘价序列的差分)进行ADF检验, 则显著,说明一阶差分后使得序列变得平稳:
## Warning in fUnitRoots::adfTest(delta.sp5d, lags = 2, type = "ct"): p-value
## smaller than printed p-value
##
## Title:
## Augmented Dickey-Fuller Test
##
## Test Results:
## PARAMETER:
## Lag Order: 2
## STATISTIC:
## Dickey-Fuller: -70.5501
## P VALUE:
## 0.01
##
## Description:
## Thu Apr 19 16:46:52 2018 by user: user
○○○○○
http://www.jiaoanw.com/%E6%95%99%E6%A1%88%E6%A8%A1%E6%9D%BF/article-36782-3.html
http://www.jiaoanw.com/
true
教案网
http://www.jiaoanw.com/%E6%95%99%E6%A1%88%E6%A8%A1%E6%9D%BF/article-36782-3.html
report
3848
## ## Call:## ar(x = dgnp, method = "mle")## ## Coefficients:## 1 2 3 4 5 6 7 8 ## 0.4318 0.1985 -0.1180 0.0189 -0.1607 0.0900 0.0615 -0.0814 ## 9 ## 0.1940 ## ## Order selected 9 sigma^2 estimated as
自已弄点水果榨汁加点酒精加点水加点糖就好了