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
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
). 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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.