[R-sig-Geo] error in spautolm spdep and model selection?

Roger Bivand Roger.Bivand at nhh.no
Sun Jan 18 10:41:33 CET 2009


On Sat, 17 Jan 2009, Michael Denslow wrote:

> Dear r-sig-geo,
>
> I am attempting to compare the results from an lm() regression with an 
> appropriate spatial regression. I have run into a problem when using the 
> spautolm function in spdep. When I include a polynomial term in the 
> model I get the following error message:
>
>> SAR <- spautolm(log10ns2a ~ log10a2a + floras2a$Field.Year +
> floras2a$mid.elev +  I(floras2a$mid.elev^2),
> listw = nb72km.w)
>
> Error in solve.default(t(X) %*% as.matrix(IlW %*% X), tol = tol.solve) :
>  system is computationally singular: reciprocal condition number = 2.07505e-17
>
> I am not sure how to interpret this. The function seems to work fine if 
> I remove the polynomial term.

For spautolm, this is a new report, and I'll try to find out how to make 
the error message clearer. What is happening is the when the squared term 
is included, X' (I - \lambda W)' \Omega (I - \lambda W) X is singular. My 
guess would be that:

SAR <- errorsarlm(log10ns2a ~ log10a2a + floras2a$Field.Year + 
floras2a$mid.elev +  I(floras2a$mid.elev^2), listw = nb72km.w)

might very well fail too - almost certainly floras2a$mid.elev and 
I(floras2a$mid.elev^2) are highly correlated. spautolm does check whether 
the X variables are aliased, but using QR, rather than the less robust 
solve.default(). Can you try changing the scale of mid.elev, which will 
then change the scale of its square?

If you believe that the variable scaling is as it should be, and want to 
proceed, set the tol.solve= argument in spautolm to a value less than 
2.07505e-17, such as 1e-17. In principle, the internal function should not 
use solve.default(), but this is the first report of it causing 
trouble since spautolm was introduced in late 2005.

>
> Perhaps to larger question is which is the appropriate SAR/CAR model to 
> use for my data. I realize that this is not an R question but any help 
> would be most appreciated! My data has some spatial autocorrelation in 
> the predictor variables. The residuals of the lm() model are not 
> autocorrelated. Also the elevation variable is strongly autocorrelated 
> and directional in my data set. As I understand it this would rule out 
> CAR as an option.

The models you are fitting are trying to harvest spatial structure in the 
residual. If there isn't any spatial structure to harvest, lm() is quite 
good enough. Spatial pattern in the X variables is not a problem, 
especially if it matches the spatial patterning in the response. Do you 
have a reference for your claims above, they sound like heresay to me? In 
this case, the only interesting spatial patterning is in the residuals - 
if they are clean, and you beleive that your model is well specified, 
there is no spatial story left.

Best wishes,

Roger

PS. access to your data set might be helpful in inserting a better error 
message into spautolm.

>
> Thank you in advance for any help you can provide,
> Michael
>
>
>
>
> Michael Denslow
>
> I.W. Carpenter Jr. Herbarium [BOON]
> Appalachian State University
> Boone, North Carolina U.S.A.
>
> -- AND --
>
> Communications Manager
> Southeastern Regional Network of Expertise and Collections
> sernec.org
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list