拟合GARCH(1,1)-R中具有协变量的模型


10

我对时间序列建模有一些经验,以简单的ARIMA模型等形式。现在,我有一些表现出波动性聚类的数据,我想尝试从数据上拟合GARCH(1,1)模型开始。

我有一个数据系列,并且我认为许多变量会影响它。因此,从基本的回归角度来看,它看起来像:

yt=α+β1xt1+β2xt2+ϵt.

但是我完全不知道如何将其实现为GARCH(1,1)-模型?我已经在中查看了rugarch-package和fGarch-package R,但是除了可以在Internet上找到的示例之外,我没有做任何有意义的事情。

Answers:


12

这是一个使用该rugarch包以及一些虚假数据的实现示例。该函数ugarchfit允许在均值方程中包含外部回归变量(请注意下面代码external.regressorsfit.specin的使用)。

要修复符号,该模型是

yt=λ0+λ1xt,1+λ2xt,2+ϵt,ϵt=σtZt,σt2=ω+αϵt12+βσt12,
xt,1xt,2tZt

本示例中使用的参数值如下。

## Model parameters
nb.period  <- 1000
omega      <- 0.00001
alpha      <- 0.12
beta       <- 0.87
lambda     <- c(0.001, 0.4, 0.2)

xt,1xt,2ytR

在此处输入图片说明

## Dependencies
library(rugarch)

## Generate some covariates
set.seed(234)
ext.reg.1 <- 0.01 * (sin(2*pi*(1:nb.period)/nb.period))/2 + rnorm(nb.period, 0, 0.0001)
ext.reg.2 <- 0.05 * (sin(6*pi*(1:nb.period)/nb.period))/2 + rnorm(nb.period, 0, 0.001)
ext.reg   <- cbind(ext.reg.1, ext.reg.2)

## Generate some GARCH innovations
sim.spec    <- ugarchspec(variance.model     = list(model = "sGARCH", garchOrder = c(1,1)), 
                          mean.model         = list(armaOrder = c(0,0), include.mean = FALSE),
                          distribution.model = "norm", 
                          fixed.pars         = list(omega = omega, alpha1 = alpha, beta1 = beta))
path.sgarch <- ugarchpath(sim.spec, n.sim = nb.period, n.start = 1)
epsilon     <- as.vector(fitted(path.sgarch))

## Create the time series
y <- lambda[1] + lambda[2] * ext.reg[, 1] + lambda[3] * ext.reg[, 2] + epsilon

## Data visualization
par(mfrow = c(3,1))
plot(ext.reg[, 1], type = "l", xlab = "Time", ylab = "Covariate 1")
plot(ext.reg[, 2], type = "l", xlab = "Time", ylab = "Covariate 2")
plot(y, type = "h", xlab = "Time")
par(mfrow = c(1,1))

拟合ugarchfit如下。

## Fit
fit.spec <- ugarchspec(variance.model     = list(model = "sGARCH",
                                                 garchOrder = c(1, 1)), 
                       mean.model         = list(armaOrder = c(0, 0),
                                                 include.mean = TRUE,
                                                 external.regressors = ext.reg), 
                       distribution.model = "norm")
fit      <- ugarchfit(data = y, spec = fit.spec)

参数估计为

## Results review
fit.val     <- coef(fit)
fit.sd      <- diag(vcov(fit))
true.val    <- c(lambda, omega, alpha, beta)
fit.conf.lb <- fit.val + qnorm(0.025) * fit.sd
fit.conf.ub <- fit.val + qnorm(0.975) * fit.sd
> print(fit.val)
#     mu       mxreg1       mxreg2        omega       alpha1        beta1 
#1.724885e-03 3.942020e-01 7.342743e-02 1.451739e-05 1.022208e-01 8.769060e-01 
> print(fit.sd)
#[1] 4.635344e-07 3.255819e-02 1.504019e-03 1.195897e-10 8.312088e-04 3.375684e-04

相应的真实值是

> print(true.val)
#[1] 0.00100 0.40000 0.20000 0.00001 0.12000 0.87000

下图显示了具有95%置信区间的参数估计值和真实值。R下面提供了用于生成它的代码。

在此处输入图片说明

plot(c(lambda, omega, alpha, beta), pch = 1, col = "red",
     ylim = range(c(fit.conf.lb, fit.conf.ub, true.val)),
     xlab = "", ylab = "", axes = FALSE)
box(); axis(1, at = 1:length(fit.val), labels = names(fit.val)); axis(2)
points(coef(fit), col = "blue", pch = 4)
for (i in 1:length(fit.val)) {
    lines(c(i,i), c(fit.conf.lb[i], fit.conf.ub[i]))
}
legend( "topleft", legend = c("true value", "estimate", "confidence interval"),
        col = c("red", "blue", 1), pch = c(1, 4, NA), lty = c(NA, NA, 1), inset = 0.01)

您如何估算参数(lambda,omega,alpha,beta)?
2017年

1
@chs通过函数获得参数估计ugarchfit
QuantIbex
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.