简体   繁体   English

尝试在R中估算GARCH模型时出错

[英]Error when attempting to estimate GARCH model in R

Here is the code I'm using to create my time series: 这是我用来创建时间序列的代码:

#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")

Here is the code I'm using to estimate my GARCH model: 这是我用来估计我的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")

I keep getting the error 我不断收到错误

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

and have no idea what is going wrong. 而且不知道出了什么问题。

system is computationally singular means it is not possible to obtain the inverse of the second derivative of the log likelihood wrt the parameters ( fit$hessian ). system is computationally singular意味着不可能通过参数( fit$hessian )获得对数似然的二阶导数的逆。 MLE estimates parameters that minimize the log likelihood function but, without it, it is not possible to satisfy the second order condition - this is in theory and the actual implementation of the package may be different. MLE会估计使对数似然函数最小化的参数,但如果没有它,就不可能满足二阶条件-这在理论上是可行的,并且程序包的实际实现可能有所不同。

With a random sample, the function works without a problem as shown below and you may check your data. 对于随机样本,该函数可以正常工作,如下所示,您可以检查数据。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM