如题,我想用rugarch包算时间序列的garch模型,包括外生变量,请问该如何编,我的程序问题在哪里。
数据见附件,1.我的变量维度是时间和国家,2.核心变量是 股指年收益率,3.外生变量是第9,10列数据。
aa<-read.csv("aa.csv",stringsAsFactors=F)
library(rugarch)
spec = ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1),external.regressors =aa[,9:10] ),
mean.model = list(armaOrder = c(1, 1),include.mean = TRUE, arfima = FALSE,external.regressors =aa[,9:10] ),
distribution.model = "sged")
fit= ugarchfit(spec = spec,aa[,c(1:2,4)])
fit
报错:
Error in optim(init[mask], armaCSS, method = optim.method, hessian = TRUE, :
'vmmin'的初始值不能为无穷大
解决方法:
gjr.spec <- ugarchspec( # start ugarch specification
variance.model = list(model = "gjrGARCH", # select Treshold-GARCH
garchOrder = c(1, 1), # GARCH(1, 1), order c(1,1) is in fact the default
external.regressors = as.matrix(dfr[, "mon"])), # monday effect in variance
# given as an external regressor. Must be
# a matrix!
mean.model = list(armaOrder = c(0, 1), # MA(1) specification
external.regressors = as.matrix(dfr[, c("mon")])), # Monday effect in the returns
# must be a matrix!
distribution.model = "sstd" # Student t as the conditional distribution
) # end ugarch specification
暂无数据