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