# DCC-GARCH模型用R语言详细实现步骤

Engle 在文章首次提出可以运用DCC-GARCH 模型(DynamicConditional Corelational Autoregressive Conditional Heteroscedasticity Model)，即动态相关多变量广义自回归条件异方差模型来度量两个或者多个不同时间序列数据的动态波动相关性。该模型放宽了CCC-GARCH模型中对时间序列数据相关性的波动系数为常数的假设条件,认为实际情况下时间序列数据波动是时变的。在这篇论文发表后，国内外很多专家学者不断对其进行理论丰富和实证扩充，逐渐建立起关于DCC-GARCH模型成熟完善的理论体系。

R代码如下：

library(ccgarch);
library(fGarch);
library(MASS);
library(FinTS);
library(tseries);
library(vars);
xt<-ts(x[,1:2],start=c(1,1));
plot(xt, plot.type = "single",col=c("red","black"),lty=1:2);
leg.names<-c("上证指数收益","道琼斯指数收益");
legend(locator(1),leg.names,lty=c(1,2), col=c("red","black"));
y=xt[,1];
z=xt[,2];
data_outline <- function(x){
n <- length(x)
m <- mean(x)
v <- var(x)
s <- sd(x)
me <- median(x)
cv <- 100*s/m
css <- sum((x-m)^2)
uss <- sum(x^2)
R <- max(x)-min(x)
R1 <- quantile(x,3/4)-quantile(x,1/4)
sm <- s/sqrt(n)
g1 <- n/((n-1)*(n-2))*sum((x-m)^3)/s^3
g2 <- ((n*(n+1))/((n-1)*(n-2)*(n-3))*sum((x-m)^4)/s^4- (3*(n-1)^2)/((n-2)*(n-3)))
data.frame(N=n, Mean=m, Var=v, std_dev=s,
Median=me, std_mean=sm, CV=cv, CSS=css, USS=uss,
R=R, R1=R1, Skewness=g1, Kurtosis=g2, row.names=1)
}
data_outline(y);
data_outline(z);
jarque.bera.test(y);
jarque.bera.test(z);
c(ucv(y,length(y)),bcv(y,length(y)));
plot(density(y,width=0.006),lty=3,ylim=c(0,80));
a<-seq(-0.1,0.1,0.001);
lines(a,dnorm(a,mean(y),sqrt(var(y))),lty=1);
leg.names<-c("Kernel Density","Normal Density");
legend(locator(1),leg.names,lty=c(3,1));
c(ucv(z,length(z)),bcv(z,length(z)));
plot(density(z,width=0.005),lty=3,ylim=c(0,80));
lines(a,dnorm(a,mean(z),sqrt(var(z))),lty=1);
leg.names<-c("Kernel Density","Normal Density");
legend(locator(1),leg.names,lty=c(3,1));
adf.test(y, alternative = c("stationary", "explosive"),k = trunc((length(y)-1)^(1/3)));
adf.test(z, alternative = c("stationary", "explosive"),k = trunc((length(z)-1)^(1/3)));
ArchTest(y,lags=3,demean=T);  #最后一项是为了去掉均值。
ArchTest(z,lags=5,demean=T);
garch.y=garch(y,order=c(1,1));
summary(garch.y);
garch.z=garch(z,order=c(1,1));
summary(garch.z);
inia=c(4.361e-07,8.327e-07);
iniA=diag(c(4.769e-02,1.349e-01));
iniB=diag(c(9.460e-01,8.546e-01));

*****完整R语言代码搜索微信公众号：统计分析分析******


04-05

09-02 3万+
04-26 1760
04-25 1万+
11-29 1728
09-05 6万+

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。