全部版块 我的主页
论坛 提问 悬赏 求职 新闻 读书 功能一区 学道会
4324 1
2019-10-22
求助
r语言的多元garch模型代码
bekk,ccc,dcc,vech,ewma
二维码

扫码加我 拉你入群

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

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

全部回复
2019-10-23 16:02:12
R语言BEKK
mf<-read.csv(file="F:/上汽集团.csv")
head(mf)

simulated <- simulateBEKK(2, 1000, c(1,1))

## Prepare the matrix:
simulated <- do.call(cbind, simulated$eps)
m<-as.data.frame(mf[,5:6])
estimated <- BEKK(m,morder = c(1, 1), params = NULL, fixed= NULL, method = "BFGS",
                verbose =F)
setwd("F:/")

simulated <- simulateBEKK(2, 1000, c(1,1))

## Prepare the matrix:
install.packages("rmgarch")
library(rmgarch)
library(m)
library(vars)
setwd("F:/1000var_bekk_garch")
mf<-read.csv(file="shuju.csv")







m<-as.matrix(mf[,2:3])
## Estimate BEKK mGARCH(1,1)
estimated <- BEKK(m)

#计算条件协方差
H12<-estimated$sd[[1]]*estimated$cor[[1]][[2]]*estimated$sd[[2]]

#市场收益率的条件方差
H22<-(estimated$sd[[1]])^2
#beta值计算
beta1<-H12/H22
beta1
beta2<-ts(beta1,start=c(2005,1),frequency = 1)
plot(beta2,main="beta")
write.csv(beta1,file="beta.csv")

H<-cbind(H12,H22)
write.csv(H,file="H.csv")
mean(beta1,na.rm=T)

library(rugarch)
ata = mf[,3], spec = spec)
cor(mf[,2:3])


data(Canada)
VARselect(Canada, lag.max = 5, type="const")
data(Canada)
m<-VAR(Canada, p = 2, type = "none")
m$datamat
VAR(Canada, p = 2, type = "const")
VAR(Canada, p = 2, type = "trend")
VAR(Canada, p = 2, type = "both")

library(mgarchBEKK)
## Not run:
sim = BEKK.sim(1000)
est = mGJR(sim$eps1, sim$eps2)
m<-as.matrix(mf[,4:5])
dccspec(m)
multispec( m )

library(mgarchBEKK)
simulated <- simulateBEKK(2, 1000, c(1,1))

## Prepare the matrix:
simulated <- do.call(cbind, simulated$eps)

## Estimate with default arguments:
estimated <- BEKK(simulated)
estimated$order
## Not run:
## Show diagnostics:
diagnoseBEKK(estimated)


原文链接http://blog.sina.com.cn/s/blog_13e5915160102x8bo.html

二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群