楼主: dedongzhuang
6703 9

[问答] R软件如何分析金融时间序列的copula,如M-Garch-copula模型 [推广有奖]

  • 1关注
  • 3粉丝

VIP

已卖:1040份资源

博士生

56%

还不是VIP/贵宾

-

威望
0
论坛币
731 个
通用积分
6.7613
学术水平
3 点
热心指数
2 点
信用等级
2 点
经验
2310 点
帖子
116
精华
0
在线时间
464 小时
注册时间
2006-11-20
最后登录
2024-4-10

楼主
dedongzhuang 发表于 2011-10-18 15:45:26 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请问大家在R中如何做copula,如模型M-Garch-Copula怎么做,程序命令怎么编,请大家帮忙,非常感谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Copula 金融时间序列 opula GARCH 时间序列 return loaded 分析 金融 undefined

沙发
DM小菜鸟 发表于 2014-12-15 16:33:52
garch-copula的程序,你可以这样做——
  
## The copula--GARCH model

require(copula)
require(rugarch)




### 1) Simulate data from two ARMA(1,1)-GARCH(1,1) processes with dependent innovations


## simulate innovation distribution
n <- 200 # sample size
d <- 2 # dimension
nu <- 3 # degrees of freedom for t
tau <- 0.5 # Kendall's tau
th <- iTau(ellipCopula("t", df=nu), tau) # corresponding parameter
cop <- ellipCopula("t", param=th, dim=d, df=nu) # define copula object
set.seed(271) # set seed
U <- rCopula(n, cop) # sample the copula
Z <- qnorm(U) # adjust margins


## Simulate joint ARMA(1,1)-GARCH(1,1) process with these innovations
##
## Recall: ARMA(p_1,q_1)-GARCH(p_2,q_2) model:
##         X_t = mu_t + sigma_t * Z_t
##        mu_t = mu + \sum_{k=1}^{p_1} \phi_k  * (X_{t-k}-\mu) +
##                    \sum_{k=1}^{q_1} \theta_k* (X_{t-k}-\mu_{t-k})
##   sigma_t^2 = \alpha_0 + \sum_{k=1}^{p_2} \alpha_k* (X_{t-k}-\mu_{t-k})^2 +
##                          \sum_{k=1}^{q_2} \beta_k * sigma_{t-k}^2
## NB: alternatively use   X_t - mu_t = sigma_t * Z_t   in last two eq.
##
## set parameters
fixed.p <- list(mu  = 1,
                ar1 = 0.5,
                ma1 = 0.3,
                omega = 2, # alpha_0 (conditional variance intercept)
                alpha1= 0.4,
                beta1 = 0.2)
varModel <- list(model = "sGARCH", garchOrder=c(1,1)) # standard GARCH
uspec <- ugarchspec(varModel, mean.model = list(armaOrder=c(1,1)),
                    fixed.pars = fixed.p,
                    distribution.model = "norm") # conditional innovation density
## note: ugarchpath(): simulate from a spec; ugarchsim(): simulate from a fitted object
X <- ugarchpath(uspec,
                n.sim= n, # simulated path length
                m.sim= d, # number of paths to simulate
                custom.dist=list(name="sample", distfit=Z)) # passing sample (n x d)-matrix
str(X, max.level=2) # => @path$sigmaSim, $seriesSim, $residSim
matplot(X@path$sigmaSim,  type="l") # plot of sigma's (conditional standard deviations)
matplot(X@path$seriesSim, type="l") # plot of X's
matplot(X@path$residSim,  type="l") # plot of Z's
plot(pobs(X@path$residSim)) # plot of Z's pseudo-observations => seem fine




### 2) Fit procedure based on the simulated data ###############################


## fit ARMA(1,1)-GARCH(1,1) process to X
## remove 'fixed.pars' from specification to be able to fit
uspec <- ugarchspec(varModel, mean.model = list(armaOrder=c(1,1)),
                    distribution.model = "norm")
fit <- apply(X@path$seriesSim, 2, function(x) ugarchfit(uspec, x))
str(fit, max.level=3)
str(fit[[1]], max.level=2) # for first time series
stopifnot(identical(fit[[1]]@fit$residuals, residuals(fit[[1]]@fit))) # => the same


## check residuals
Z. <- sapply(fit, function(fit.) residuals(fit.@fit))
U. <- pobs(Z.)
plot(U., # plot of Z's pseudo-observations => seem fine
     xlab=expression(italic(hat(U)[1])),
     ylab=expression(italic(hat(U)[2])))


## fit a t copula to the residuals Z
fitcop <- fitCopula(ellipCopula("t", dim=2), data=U., method="mpl")
rbind(est = fitcop@estimate, true = c(th, nu)) # hat{rho}, hat{nu}; close to th, nu




### 3) Simulate from the fitted model ##########################################


## simulate from the fitted copula model
U.. <- rCopula(n, fitcop@copula)
Z.. <- qnorm(U..)


## simulate from the fitted time series model
X..sim <- lapply(1:d, function(j)
                 ugarchsim(fit[[j]], n.sim=n, m.sim=1,
                           custom.dist=list(name="sample",
                           distfit=Z..[,j, drop=FALSE]))@simulation)
str(X..sim, max.level=3)
X..Z <- sapply(X..sim, `[[`, "residSim")
X.. <- sapply(X..sim, `[[`, "seriesSim")


plot(X..Z, main="residSim"); abline(h=0,v=0, lty=2, col=adjustcolor(1, .5))
plot(X.., main="seriesSim"); abline(h=0,v=0, lty=2, col=adjustcolor(1, .5))
matplot(pobs(X..), type="l")
plot(pobs(X..), main="pobs(series..)"); rect(0,0,1,1, border=adjustcolor(1, 1/2))

已有 1 人评分热心指数 收起 理由
ryoeng + 1 热心帮助其他会员

总评分: 热心指数 + 1   查看全部评分

藤椅
dedongzhuang 发表于 2014-12-16 15:40:38
非常感谢

板凳
如假包换 发表于 2015-4-7 21:06:00
从概率积分变换到K-S检验这一部分的程序呢,我做出来的P值很小

报纸
李燕letty 学生认证  发表于 2015-4-9 10:13:29 来自手机
Mark

地板
moretc 学生认证  发表于 2015-10-6 17:25:43
DM小菜鸟 发表于 2014-12-15 16:33
garch-copula的程序,你可以这样做——
  
## The copula--GARCH model
楼主,能不能把Coupla的代码全部发给我,或者推荐些有代码的书籍,1225445386@qq.com,不胜感激!

7
moretc 学生认证  发表于 2015-10-6 17:26:14
DM小菜鸟 发表于 2014-12-15 16:33
garch-copula的程序,你可以这样做——
  
## The copula--GARCH model
楼主,能不能把Coupla的代码全部发给我,或者推荐些有代码的书籍,1225445386@qq.com,不胜感激!

8
ryoeng 在职认证  发表于 2018-9-20 02:59:32
提示: 作者被禁止或删除 内容自动屏蔽

9
hifinecon 发表于 2018-9-20 16:20:02 来自手机
dedongzhuang 发表于 2011-10-18 15:45
请问大家在R中如何做copula,如模型M-Garch-Copula怎么做,程序命令怎么编,请大家帮忙,非常感谢
thank LZ for your kindness

10
福克斯宾得 发表于 2020-10-14 10:28:59
感谢分析

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-10 01:07