尝试估计R中的GARCH模型时出错

时间:2015-04-25 18:32:44

标签: r time-series rstudio

以下是我用来创建时间序列的代码:

#Violent Crimes Time Series
violent <- crime[,1]
viol.ts <- ts(violent, start=1960, end=2013, frequency=1)
viol.train <- window(viol.ts, start=1960, end=2003)
viol.test <- window(viol.ts, start=2004)
ts.plot(viol.ts, type="l", xlab="Year", ylab="Total Crimes", main="Violent Crime, 1960-2013")

以下是我用来估算我的GARCH模型的代码:

#GARCH
viol.g <- garchFit(~arma(1,1) + garch(1,1), viol.ts)
summary(viol.g)
plot(viol.g)
plot(viol.g@h.t, type="l")
plot (viol.g@fitted, type="l")

我一直收到错误

Error in solve.default(fit$hessian) : system is computationally singular: reciprocal condition number = 3.27071e-20

并且不知道出了什么问题。

1 个答案:

答案 0 :(得分:0)

system is computationally singular表示不可能获得对数似然w.r.t的二阶导数的倒数。参数(fit$hessian)。 MLE估计最小化对数似然函数的参数,但是没有它,就不可能满足二阶条件 - 这在理论上并且包的实际实现可能不同。

使用随机样本,该功能可以正常运行,如下所示,您可以检查数据。

library(fGarch)

#Violent Crimes Time Series
set.seed(1237)
violent <- sample(log(10:30), 53, replace = TRUE)
viol.ts <- ts(violent, start=1960, end=2013, frequency=1)
viol.train <- window(viol.ts, start=1960, end=2003)
viol.test <- window(viol.ts, start=2004)
ts.plot(viol.ts, type="l", xlab="Year", ylab="Total Crimes", main="Violent Crime, 1960-2013")

#GARCH
viol.g <- garchFit(~arma(1,1) + garch(1,1), viol.ts)
summary(viol.g)
plot(viol.g)
plot(viol.g@h.t, type="l")
plot (viol.g@fitted, type="l")

Title:
  GARCH Modelling 

Call:
  garchFit(formula = ~arma(1, 1) + garch(1, 1), data = viol.ts) 

Mean and Variance Equation:
  data ~ arma(1, 1) + garch(1, 1)
<environment: 0x0000000030109de0>
  [data = viol.ts]

Conditional Distribution:
  norm 

Coefficient(s):
  mu          ar1          ma1        omega       alpha1        beta1  
5.42739444  -0.83160492   0.90173149   0.06406353   0.00000001   0.39089064