On Sun, 5 Jun 2016, Pascal Title wrote:

Hi,

I am trying to fit a simultaneous autoregressive model to some data using
the spdep package. In order to identify the appropriate spatial distance to
use, I use the correlog function to find the distance at which spatial
autocorrelation of the residuals from a linear model drops to 0.

When I run this code, I get a warning that states:
In errorsarlm(dat$rangeSize ~ dat$clim, listw = nlw, na.action = na.omit,  :
 inversion of asymptotic covariance matrix failed for tol.solve = 1e-10
 reciprocal condition number = 1.64249e-12 - using numerical Hessian.

I don't know enough about these models or the model fitting procedure to
understand whether or not this is a warning that can safely be ignored, or
if this is an indication that the results of the regression cannot be
trusted. Is there something I can/should do to improve the model fitting
procedure?

This is like: "I don't know enough about poisonous mushrooms, so I'll just eat them raw to check the effect"?

Computers do not do conceptual linear alegebra, so that in doing numerical linear algebra, you have to think of the scaling of matrices, here in calculating the variance-covariance matrix of the model coefficients. If the scale is too large at the squared level, 1e-3 and 1e+3 say before squaring, you run out of road, and may choose to set a smaller tolerance check (walking closer to the edge of a cliff). See the tol.solve= argument where all of this is documented.

But really - never drive a car you cannot re-assemble yourself if your life, other people's lives or your career depends on it. All of this really is well documented in ?solve and ?errorsarlm.

I won't say RTFM, but in this case it would be justified.

Roger



Thanks!

-Pascal

the data can be downloaded from here:
https://dl.dropboxusercontent.com/u/34644229/sampleDat.rds

code:

library(ncf)
library(spdep)

dat <- readRDS('sampleDat.rds')

fit1 <- lm(dat$rangeSize ~ dat$clim)
x <- dat$long
y <- dat$lat
z <- fit1$residuals
co <- correlog(x, y, z, increment = 500, resamp = 0, latlon = FALSE, na.rm
= TRUE)
nei <- dnearneigh(cbind(x, y), d1 = 0, d2 = co$x.intercept, longlat = FALSE)
nlw <- nb2listw(nei, style = "W", zero.policy = TRUE)

m1 <- errorsarlm(dat$rangeSize ~ dat$clim, listw = nlw, na.action =
na.omit, zero.policy = TRUE)
summary(m1, Nagelkerke = TRUE)

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: roger.biv...@nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to