关于数据挖掘:ARMAGARCHCOPULA模型和金融时间序列案例附代码数据

2次阅读

共计 5231 个字符,预计需要花费 14 分钟才能阅读完成。

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

最近我被要求撰写对于金融工夫序列的 copulas 的考察

从读取数据中取得各种模型的形容,包含一些图形和统计输入。

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

而后咱们能够绘制这三个工夫序列

1 1997-01-10 2.73672 2.25465 3.3673 1.5400

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

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

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

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

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

这个想法是在这里应用一些多变量 ARMA-GARCH 过程。这里的启发式是第一局部用于模仿工夫序列平均值的动静,第二局部用于模仿工夫序列方差的动静。

本文思考了两种模型

  • 对于 ARMA 模型残差的多变量 GARCH 过程(或方差矩阵动力学模型)
  • 对于 ARMA-GARCH 过程残差的多变量模型(基于 copula)

因而,这里将思考不同的序列,作为不同模型的残差取得。咱们还能够将这些残差标准化。

ARMA 模型

> fit1 = arima(x = dat [,1],order = c(2,0,1))> fit2 = arima(x = dat [,2],order = c(1,0,1))> fit3 = arima(x = dat [,3],order = c(1,0,1))> m < - apply(dat_arma,2,mean)> v < - apply(dat_arma,2,var)> dat_arma_std < - t((t(dat_arma)-m)/ sqrt(v))

ARMA-GARCH 模型

> fit1 = garchFit(formula = ~arma(2,1)+ garch(1,1),data = dat [,1],cond.dist =“std”)> fit2 = garchFit(formula = ~arma(1,1)+ garch(1,1),data = dat [,2],cond.dist =“std”)> fit3 = garchFit(formula = ~arma(1,1)+ garch(1,1),data = dat [,3],cond.dist =“std”)> m_res < - apply(dat_res,2,mean)> v_res < - apply(dat_res,2,var)> 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 模型

能够思考的第一个模型是协方差矩阵的多变量 EWMA,

> ewma = EWMAvol(dat_res_std,lambda = 0.96)

波动性

> emwa_series_vol = function(i = 1){+ lines(Time,dat_arma [,i] + 40,col =“gray”)+ j = 1
+ if(i == 2)j = 5
+ if(i == 3)j = 9


点击题目查阅往期内容

R 语言基于 ARMA-GARCH 过程的 VaR 拟合和预测

左右滑动查看更多

01

02

03

04

隐含相关性

> emwa_series_cor = function(i = 1,j = 2){
+ if((min(i,j)== 1)&(max(i,j)== 2)){+ a = 1; B = 9; AB = 3}
+ r = ewma $ Sigma.t [,ab] / sqrt(ewma $ Sigma.t [,a] *
+ ewma $ Sigma.t [,b])+ plot(Time,r,type =“l”,ylim = c(0,1))+}

多变量 GARCH,即 BEKK(1,1)模型,例如应用:

> bekk = BEKK11(dat_arma)> bekk_series_vol function(i = 1){+ plot(Time,$ Sigma.t [,1],type =“l”,+ ylab =(dat)[i],col =“white”,ylim = c(0,80))+ lines(Time,dat_arma [,i] + 40,col =“gray”)+ j = 1
+ if(i == 2)j = 5

+ if(i == 3)j = 9

> bekk_series_cor = function(i = 1,j = 2){+ a = 1; B = 5; AB = 2}
+ a = 1; B = 9; AB = 3}
+ a = 5; B = 9; AB = 6}
+ r = bk $ Sigma.t [,ab] / sqrt(bk $ Sigma.t [,a] *
+ bk $ Sigma.t [,b])

从单变量 GARCH 模型中模仿残差

第一步可能是思考残差的一些动态(联结)散布。单变量边缘散布是

边缘密度的轮廓(应用双变量核预计器取得)

也能够将 copula 密度可视化(下面有一些非参数估计,上面是参数 copula)

> copula_NP = function(i = 1,j = 2){
+ n = nrow(uv)+ s = 0.3

+ norm.cop < - normalCopula(0.5)+ norm.cop < - normalCopula(fitCopula(norm.cop,uv)@estimate)+ dc = function(x,y)dCopula(cbind(x,y),norm.cop)+ ylab = names(dat)[j],zlab =“copule Gaussienne”,ticktype =“detailed”,zlim = zl)+
+ t.cop < - tCopula(0.5,df = 3)+ t.cop < - tCopula(t.fit [1],df = t.fit [2])+ ylab = names(dat)[j],zlab =“copule de Student”,ticktype =“detailed”,zlim = zl)+}

能够思考这个函数,

计算三个序列的的教训版本,并将其与一些参数版本进行比拟,

>

> lambda = function(C){
+ l = function(u)pcopula(C,cbind(u,u))/ u
+ v = Vectorize(l)(u)+ return(c(v,rev(v)))+}
>

> graph_lambda = function(i,j){
+ X = dat_res
+ U = rank(X [,i])/(nrow(X)+1)+ V = rank(X [,j])/(nrow(X)+1)+ normal.cop < - normalCopula(.5,dim = 2)+ t.cop < - tCopula(.5,dim = 2,df = 3)+ fit1 = fitCopula(normal.cop,cbind(U,V),method =“ml”)d(U,V),method =“ml”)+ C1 = normalCopula(fit1 @ copula @ parameters,dim = 2)+ C2 = tCopula(fit2 @ copula @ parameters [1],dim = 2,df = trunc(fit2 @ copula @ parameters [2]))+

但人们可能想晓得相关性是否随工夫稳固。

> time_varying_correl_2 = function(i = 1,j = 2,+ nom_arg =“Pearson”){+ uv = dat_arma [,c(i,j)]
nom_arg))[1,2]
+}
> time_varying_correl_2(1,2)> time_varying_correl_2(1,2,“spearman”)> time_varying_correl_2(1,2,“kendall”)

斯皮尔曼与时变排名相关系数

或肯德尔 相关系数

为了模型的相关性,思考 DCC 模型(S)

> m2 = dccFit(dat_res_std)> m3 = dccFit(dat_res_std,type =“Engle”)> R2 = m2 $ rho.t
> R3 = m3 $ rho.t

要取得一些预测,应用例如

> garch11.spec = ugarchspec(mean.model = list(armaOrder = c(2,1)),variance.model = list(garchOrder = c(1,1),model =“GARCH”))> dcc.garch11.spec = dccspec(uspec = multispec(replicate(3,garch11.spec)),dccOrder = c(1,1),distribution =“mvnorm”)> dcc.fit = dccfit(dcc.garch11.spec,data = dat)> fcst = dccforecast(dcc.fit,n.ahead = 200)


本文摘选 R 语言 ARMA-GARCH-COPULA 模型和金融工夫序列案例 ,点击“ 浏览原文”获取全文残缺材料。


点击题目查阅往期内容

工夫序列剖析:ARIMA GARCH 模型剖析股票价格数据
GJR-GARCH 和 GARCH 稳定率预测普尔指数工夫序列和 Mincer Zarnowitz 回归、DM 测验、JB 测验
【视频】工夫序列剖析:ARIMA-ARCH / GARCH 模型剖析股票价格
工夫序列 GARCH 模型剖析股市稳定率
PYTHON 用 GARCH、离散随机稳定率模型 DSV 模仿预计股票收益工夫序列与蒙特卡洛可视化
极值实践 EVT、POT 超阈值、GARCH 模型剖析股票指数 VaR、条件 CVaR:多元化投资组合预测危险测度剖析
Garch 稳定率预测的区制转移交易策略
金融工夫序列模型 ARIMA 和 GARCH 在股票市场预测利用
工夫序列分析模型:ARIMA-ARCH / GARCH 模型剖析股票价格
R 语言危险价值:ARIMA,GARCH,Delta-normal 法滚动预计 VaR(Value at Risk)和回测剖析股票数据
R 语言 GARCH 建模罕用软件包比拟、拟合规范普尔 SP 500 指数稳定率工夫序列和预测可视化
Python 金融工夫序列模型 ARIMA 和 GARCH 在股票市场预测利用
MATLAB 用 GARCH 模型对股票市场收益率工夫序列稳定的拟合与预测 R 语言 GARCH-DCC 模型和 DCC(MVT)建模预计
Python 用 ARIMA、GARCH 模型预测剖析股票市场收益率工夫序列
R 语言中的工夫序列分析模型:ARIMA-ARCH / GARCH 模型剖析股票价格
R 语言 ARIMA-GARCH 稳定率模型预测股票市场苹果公司日收益率工夫序列
Python 应用 GARCH,EGARCH,GJR-GARCH 模型和蒙特卡洛模仿进行股价预测
R 语言工夫序列 GARCH 模型剖析股市稳定率
R 语言 ARMA-EGARCH 模型、集成预测算法对 SPX 理论稳定率进行预测
matlab 实现 MCMC 的马尔可夫转换 ARMA – GARCH 模型预计
Python 应用 GARCH,EGARCH,GJR-GARCH 模型和蒙特卡洛模仿进行股价预测
应用 R 语言对 S&P500 股票指数进行 ARIMA + GARCH 交易策略
R 语言用多元 ARMA,GARCH ,EWMA, ETS, 随机稳定率 SV 模型对金融工夫序列数据建模
R 语言股票市场指数:ARMA-GARCH 模型和对数收益率数据探索性剖析
R 语言多元 Copula GARCH 模型工夫序列预测
R 语言应用多元 AR-GARCH 模型掂量市场危险
R 语言中的工夫序列分析模型:ARIMA-ARCH / GARCH 模型剖析股票价格
R 语言用 Garch 模型和回归模型对股票价格剖析
GARCH(1,1),MA 以及历史模拟法的 VaR 比拟
matlab 预计 arma garch 条件均值和方差模型 R 语言 POT 超阈值模型和极值实践 EVT 剖析

正文完
 0