R中的garchFit()在所有拟合值中返回相同的数字

时间:2012-08-05 16:13:19

标签: r statistics

我曾尝试在R中使用garchFit并发现一些非常奇怪的东西,似乎所有的装配都是一样的。我尝试在R页面中使用该示例并找到相同的结果。

如果您打开R并输入以下内容:

library(fGarch);
## UNIVARIATE TIME SERIES INPUT:
# In the univariate case the lhs formula has not to be specified ...
# A numeric Vector from default GARCH(1,1) - fix the seed:
N = 200
x.vec = as.vector(garchSim(garchSpec(rseed = 1985), n = N)[,1])
garchFit(~ garch(1,1), data = x.vec, trace = FALSE)
# An univariate timeSeries object with dummy dates:
x.timeSeries = dummyDailySeries(matrix(x.vec), units = "GARCH11")
gfit = garchFit(~ garch(1,1), data = x.timeSeries, trace = FALSE)

然后进行以下健全性检查似乎表明残差是正确计算的:

gfit@residuals == (x.vec - gfit@fitted)

但是如果你检查gfit @ fits的内容,你会发现所有的值都是一样的!所以基本上garchFit函数找到了一条水平线?

这个例子是期望的吗?

1 个答案:

答案 0 :(得分:6)

GARCH对系列的方差进行建模,因此我们不会期望拟合值(系列平均值的估计值)会发生变化,因为您所做的就是为方差指定模型。

暗示您所安装的模型中的平均值为ARMA(0,0):

R> gfit = garchFit(~ garch(1,1), data = x.timeSeries, trace = TRUE)

Series Initialization:
 ARMA Model:                arma
 Formula Mean:              ~ arma(0, 0)
 GARCH Model:               garch
 Formula Variance:          ~ garch(1, 1)

如果您使用平均模型和方差拟合系列,则拟合值执行会有所不同:

R> gfit2 = garchFit(~ arma(1,1) + garch(1,1), data = x.timeSeries, trace = FALSE)
R> head(gfit2@fitted)
   1970-01-01    1970-01-02    1970-01-03    1970-01-04    1970-01-05 
-0.0010093158 -0.0004840687 -0.0002678956 -0.0006093776 -0.0003781936 
   1970-01-06 
 0.0004521798