time series - Error when attempting to estimate GARCH model in R -
here code i'm using create 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 code i'm using estimate 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 error
error in solve.default(fit$hessian) : system computationally singular: reciprocal condition number = 3.27071e-20
and have no idea going wrong.
system computationally singular
means not possible obtain inverse of second derivative of log likelihood w.r.t. parameters (fit$hessian
). mle estimates parameters minimize log likelihood function but, without it, not possible satisfy second order condition - in theory , actual implementation of package may different.
with random sample, function works without problem shown below , may check 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 , 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
Comments
Post a Comment