[R] Error in solve.default(Hessian) : system is computationally singular

Desislava Kavrakova dkavrakova at yahoo.com
Fri Sep 12 22:00:47 CEST 2008


Hello everyone,
I'm trying to estimate the parameters of the returns series attached using the GARCH code below, but I get the following error message:


Error in solve.default(Hessian) : 
  system is computationally singular: reciprocal condition number = 0
Error in diag(solve(Hessian)) : 
  error in evaluating the argument 'x' in selecting a method for function 'diag'

Can anyone help me with this? I don't understand what the problem is.

Many thanks,
Desislava Kavrakova


Code:

garchfitS<-function(x){
x<<-ts(x)
r<<-0.05/365
n<<-length(x)

Mean = mean(x); Var = var(x); S = 1e-6
param = c(alpha0 = Var, alpha = 0.1, beta = 0.8)
lowerB = c(alpha0 = S^2, alpha = S, beta = S)
upperB = c(alpha0 = 100*Var, alpha = 1-S, beta = 1-S)

llh<-function(p){
alpha0<-p[1]
alpha<-p[2]
beta<-p[3]
hh<-Var
for (i in 2:n){
hh[i]<-alpha0+alpha*(x[i-1]-r+0.5*hh[i-1])^2+beta*hh[i-1]
}
hh<-ts(hh)
h<-sqrt(abs(hh))
z<-(x-r+0.5*hh)/h
-(-(sum(0.5*(log(hh[2:n])+(z[2:n])^2))))
}

fit<-nlminb(param, llh, lower=lowerB, upper=upperB)
Hessian<-hessian(llh,fit$par)
se.coef = sqrt(diag(solve(Hessian)))
tval = fit$par/se.coef
matcoef = cbind(fit$par,se.coef, tval, 2*(1-pnorm(abs(tval))))
dimnames(matcoef) = list(names(tval), c(" Estimate", 
" Std. Error", " t value", "Pr(>|t|)"))
printCoefmat(matcoef, digits = 6, signif.stars = TRUE)
}


      


More information about the R-help mailing list