Alberto Jiménez Valverde
2008-Oct-08 14:44 UTC
[R] Error in spdep: system is computationally singular
Hi all,
I am trying to run an autologistic model using the function errorsarlm from
spdep package.
**I built an XY matrix extracting the two colums from matriz**
coords1<-matriz[matriz$casos1==1, c(4,5)]
coords1<-as.matrix(coords1)
**I identify neighbours of region points**
nb20<-dnearneigh(coords1,0,20,longlat=TRUE)
** I build a neighbours list with spatial weights**
nb20.w<-nb2listw(nb20, glist=NULL, style="W", zero.policy=TRUE)
**I run a glm**
glm1<-glm(matriz$sp~poly(matriz$iso,3)+poly(matriz$tmax,3)+poly(matriz$mdr,3)+poly(matriz$twq,3)+poly(matriz$tmin,3)+poly(matriz$pdq,3)+poly(matriz$trng,3),data=matriz,
subset=matriz$casos1>0, family=binomial)
glm.scope<-list("var1"=~1+iso+poly(iso,2)+poly(iso,3),"var2"=~1+tmax+poly(tmax,2)+poly(tmax,3),"var3"=~1+mdr+poly(mdr,2)+poly(mdr,3),"var4"=~1+twq+poly(twq,2)+poly(twq,3),"var5"=~1+tmin+poly(tmin,2)+poly(tmin,3),"var6"=~1+pdq+poly(pdq,2)+poly(pdq,3),"var7"=~1+trng+poly(trng,2)+poly(trng,3),"var8"=~1+mdr+poly(mdr,2)+poly(mdr,3))
final.glm1<-step.gam(glm1,glm.scope,direction="back")
**I want to estimate the spatial simultaneous autoregressive error model**
res20<-errorsarlm(finalglm1, listw=nb20.w, zero.policy=TRUE)
But here I receive the following error message:
Error in solve.default(asyvar, tol = tol.solve) :
system is computationally singular: reciprocal condition number = 2.8713e-12
What is happening? What does this message mean?
Thanks a lot,
Alberto
---------------------------------------
Alberto Jiménez-Valverde
Natural History Museum and Biodiversity Research Center
The University of Kansas
Lawrence, Kansas 66045 USA
email 1: ajvalv@ku.edu
email 2: alberto.jimenez.valverde@gmail.com
CV: http://www.biogeografia.com/CV/ajimenez/albertojimenezvalverde.htm
[[alternative HTML version deleted]]
Alberto Jim?nez Valverde <ajvalv <at> ku.edu> writes:> > Hi all, > > I am trying to run an autologistic model using the function errorsarlm fromspdep package.>...> > **I want to estimate the spatial simultaneous autoregressive error model** > > res20<-errorsarlm(finalglm1, listw=nb20.w, zero.policy=TRUE) > > But here I receive the following error message: > > Error in solve.default(asyvar, tol = tol.solve) : > system is computationally singular: reciprocal condition number = 2.8713e-12 > > What is happening? What does this message mean??errorsarlm says: The asymptotic standard error of $lambda$ is only computed when method=eigen, because the full matrix operations involved would be costly for large n typically associated with the choice of method="spam" or "Matrix". The same applies to the coefficient covariance matrix. Taken as the asymptotic matrix from the literature, it is typically badly scaled, being block-diagonal, and with the elements involving lambda being very small, while other parts of the matrix can be very large (often many orders of magnitude in difference). It often happens that the 'tol.solve' argument needs to be set to a smaller value than the default, or the RHS variables can be centred or reduced in range. My guess would be that the scalings of the variables in finalglm1 are extreme compared to the fitted lambda. Since you don't have much control over the RHS, just set tol.solve=1e-12 to get a result. Given that you've manipulated the data a good deal, I wouldn't rely on the output standard errors for inference, though. Roger Bivand> > Thanks a lot, > > Alberto >