最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

R語(yǔ)言ARMA-GARCH-COPULA模型和金融時(shí)間序列案例

2021-01-22 23:06 作者:拓端tecdat  | 我要投稿

原文?http://tecdat.cn/?p=3385

最近我被要求撰寫關(guān)于金融時(shí)間序列的copulas的調(diào)查。 從讀取數(shù)據(jù)中獲得各種模型的描述,包括一些圖形和統(tǒng)計(jì)輸出。

?



  1. > oil = read.xlsx(temp,sheetName =“DATA”,dec =“,”)


?

然后我們可以繪制這三個(gè)時(shí)間序列

  1. 1 1997-01-10 2.73672 2.25465 3.3673 1.5400


  2. 2 1997-01-17 -3.40326 -6.01433 -3.8249 -4.1076


  3. 3 1997-01-24 -4.09531 -1.43076 -6.6375 -4.6166


  4. 4 1997-01-31 -0.65789 0.34873 0.7326 -1.5122


  5. 5 1997-02-07 -3.14293 -1.97765 -0.7326 -1.8798


  6. 6 1997-02-14 -5.60321 -7.84534 -7.6372 -11.0549

這個(gè)想法是在這里使用一些多變量ARMA-GARCH過(guò)程。這里的啟發(fā)式是第一部分用于模擬時(shí)間序列平均值的動(dòng)態(tài),第二部分用于模擬時(shí)間序列方差的動(dòng)態(tài)。

本文考慮了兩種模型

  • 關(guān)于ARMA模型殘差的多變量GARCH過(guò)程(或方差矩陣動(dòng)力學(xué)模型)

  • 關(guān)于ARMA-GARCH過(guò)程殘差的多變量模型(基于copula)

因此,這里將考慮不同的序列,作為不同模型的殘差獲得。我們還可以將這些殘差標(biāo)準(zhǔn)化。

ARMA模型

  1. > fit1 = arima(x = dat [,1],order = c(2,0,1))

  2. > fit2 = arima(x = dat [,2],order = c(1,0,1))

  3. > fit3 = arima(x = dat [,3],order = c(1,0,1))

  4. > m < - apply(dat_arma,2,mean)

  5. > v < - apply(dat_arma,2,var)

  6. > dat_arma_std < - t((t(dat_arma)-m)/ sqrt(v))

?

ARMA-GARCH模型

  1. > fit1 = garchFit(formula = ~arma(2,1)+ garch(1,1),data = dat [,1],cond.dist =“std”)

  2. > fit2 = garchFit(formula = ~arma(1,1)+ garch(1,1),data = dat [,2],cond.dist =“std”)

  3. > fit3 = garchFit(formula = ~arma(1,1)+ garch(1,1),data = dat [,3],cond.dist =“std”)

  4. > m_res < - apply(dat_res,2,mean)

  5. > v_res < - apply(dat_res,2,var)

  6. > dat_res_std = cbind((dat_res [,1] -m_res [1])/ sqrt(v_res [1]),(dat_res [,2] -m_res [2])/ sqrt(v_res [2]),(dat_res [ ,3] -m_res [3])/ SQRT(v_res [3]))

?

?

多變量GARCH模型

可以考慮的第一個(gè)模型是協(xié)方差矩陣多變量EWMA,

> ewma = EWMAvol(dat_res_std,lambda = 0.96)

?

波動(dòng)性

  1. > emwa_series_vol = function(i = 1){

  2. + lines(Time,dat_arma [,i] + 40,col =“gray”)

  3. + j = 1

  4. + if(i == 2)j = 5

  5. + if(i == 3)j = 9

?

隱含相關(guān)性

  1. > emwa_series_cor = function(i = 1,j = 2){

  2. + if((min(i,j)== 1)&(max(i,j)== 2)){

  3. + a = 1; B = 9; AB = 3}

  4. + r = ewma $ Sigma.t [,ab] / sqrt(ewma $ Sigma.t [,a] *

  5. + ewma $ Sigma.t [,b]

  6. + plot(Time,r,type =“l(fā)”,ylim = c(0,1))

  7. +}

?

多變量GARCH,即BEKK(1,1)模型,例如使用:

  1. > bekk = BEKK11(dat_arma)

  2. > bekk_series_vol function(i = 1){

  3. + plot(Time, $ Sigma.t [,1],type =“l(fā)”,

  4. + ylab = (dat)[i],col =“white”,ylim = c(0,80))

  5. + lines(Time,dat_arma [,i] + 40,col =“gray”)

  6. + j = 1

  7. + if(i == 2)j = 5


  8. + if(i == 3)j = 9


  9. > bekk_series_cor = function(i = 1,j = 2){

  10. + a = 1; B = 5; AB = 2}

  11. + a = 1; B = 9; AB = 3}

  12. + a = 5; B = 9; AB = 6}

  13. + r = bk $ Sigma.t [,ab] / sqrt(bk $ Sigma.t [,a] *

  14. + bk $ Sigma.t [,b]

?


?

從單變量GARCH模型中模擬殘差

第一步可能是考慮殘差的一些靜態(tài)(聯(lián)合)分布。單變量邊緣分布是

邊緣密度的輪廓(使用雙變量核估計(jì)器獲得)?

也可以將copula密度可視化(上面有一些非參數(shù)估計(jì),下面是參數(shù)copula)

  1. > copula_NP = function(i = 1,j = 2){

  2. + n = nrow(uv)

  3. + s = 0.3


  4. + norm.cop < - normalCopula0.5

  5. + norm.cop < - normalCopulafitCopulanorm.cop,uv)@estimate

  6. + dc = function(x,y)dCopula(cbind(x,y),norm.cop)

  7. + ylab = names(dat)[j],zlab =“copule Gaussienne”,ticktype =“detailed”,zlim = zl)

  8. +

  9. + t.cop < - tCopula0.5,df = 3)

  10. + t.cop < - tCopulat.fit [1],df = t.fit [2])

  11. + ylab = names(dat)[j],zlab =“copule de Student”,ticktype =“detailed”,zlim = zl)

  12. +}

?

可以考慮這個(gè)

函數(shù),

計(jì)算三個(gè)序列的的經(jīng)驗(yàn)版本,并將其與一些參數(shù)版本進(jìn)行比較,

  1. >


  2. > lambda = function(C){

  3. + l = function(u)pcopula(C,cbind(u,u))/ u

  4. + v = Vectorize(l)(u)

  5. + return(c(v,rev(v)))

  6. +}

  7. >


  8. > graph_lambda = function(i,j){

  9. + X = dat_res

  10. + U = rank(X [,i])/(nrow(X)+1)

  11. + V = rank(X [,j])/(nrow(X)+1)


  12. + normal.cop < - normalCopula(.5,dim = 2)

  13. + t.cop < - tCopula(.5,dim = 2,df = 3)

  14. + fit1 = fitCopula(normal.cop,cbind(U,V),method =“ml”)

  15. d(U,V),method =“ml”)

  16. + C1 = normalCopula(fit1 @ copula @ parameters,dim = 2)

  17. + C2 = tCopula(fit2 @ copula @ parameters [1],dim = 2,df = trunc(fit2 @ copula @ parameters [2]))

  18. +

但人們可能想知道相關(guān)性是否隨時(shí)間穩(wěn)定。

  1. > time_varying_correl_2 = function(i = 1,j = 2,

  2. + nom_arg =“Pearson”){

  3. + uv = dat_arma [,c(i,j)]

  4. nom_arg))[1,2]

  5. +}

  6. > time_varying_correl_2(1,2)

  7. > time_varying_correl_2(1,2,“spearman”)

  8. > time_varying_correl_2(1,2,“kendall”)

?

斯皮爾曼與時(shí)變排名相關(guān)系數(shù)

或肯德爾?相關(guān)系數(shù)

為了模型的相關(guān)性,考慮DCC模型(S)

  1. > m2 = dccFit(dat_res_std)

  2. > m3 = dccFit(dat_res_std,type =“Engle”)

  3. > R2 = m2 $ rho.t

  4. > R3 = m3 $ rho.t

?

要獲得一些預(yù)測(cè), 使用例如

  1. > garch11.spec = ugarchspec(mean.model = list(armaOrder = c(2,1)),variance.model = list(garchOrder = c(1,1),model =“GARCH”))

  2. > dcc.garch11.spec = dccspec(uspec = multispec(replicate(3,garch11.spec)),dccOrder = c(1,1),

  3. distribution =“mvnorm”)

  4. > dcc.fit = dccfit(dcc.garch11.spec,data = dat)

  5. > fcst = dccforecast(dcc.fit,n.ahead = 200)

?

?

最受歡迎的見解

1.HAR-RV-J與遞歸神經(jīng)網(wǎng)絡(luò)(RNN)混合模型預(yù)測(cè)和交易大型股票指數(shù)的高頻波動(dòng)率

2.R語(yǔ)言中基于混合數(shù)據(jù)抽樣(MIDAS)回歸的HAR-RV模型預(yù)測(cè)GDP增長(zhǎng)

3.波動(dòng)率的實(shí)現(xiàn):ARCH模型與HAR-RV模型

4.R語(yǔ)言ARMA-EGARCH模型、集成預(yù)測(cè)算法對(duì)SPX實(shí)際波動(dòng)率進(jìn)行預(yù)測(cè)

5.GARCH(1,1),MA以及歷史模擬法的VaR比較

6.R語(yǔ)言多元COPULA GARCH 模型時(shí)間序列預(yù)測(cè)

7.R語(yǔ)言基于ARMA-GARCH過(guò)程的VAR擬合和預(yù)測(cè)

8.matlab預(yù)測(cè)ARMA-GARCH 條件均值和方差模型

9.R語(yǔ)言對(duì)S&P500股票指數(shù)進(jìn)行ARIMA + GARCH交易策略


R語(yǔ)言ARMA-GARCH-COPULA模型和金融時(shí)間序列案例的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
尼勒克县| 太仓市| 永州市| 泰州市| 梓潼县| 扎鲁特旗| 泸溪县| 静宁县| 仪征市| 枣阳市| 会东县| 商南县| 太保市| 临西县| 肇源县| 扬州市| 江门市| 姚安县| 千阳县| 仲巴县| 当雄县| 岑巩县| 石泉县| 资中县| 连平县| 莱州市| 仙居县| 通辽市| 鄂温| 白沙| 独山县| 大新县| 磐安县| 高阳县| 镇原县| 泸州市| 宜春市| 南开区| 东兴市| 台前县| 墨江|