[R-sig-Geo] Help to generate diagnostic plots from spatial regression

Roger Bivand Roger.Bivand at nhh.no
Wed Feb 4 19:02:14 CET 2009


On Wed, 4 Feb 2009, Ram Pandit wrote:

> Dear all,
>
> Pardon me for my limited knowledge in R.  I am trying to generate the plot
> of fitted value vs. residual from a spatial regression like in ordinary
> regression, if possible.  I tried the followings but did not get what I want
> (different diagnostic plots that can be generated by plot() in linear
> regression). Any hints will be appreciated.
>
>> library(spdep)
> fit1<-lagsarlm(y~x1+x2+x3,data=data1,weight file,zero.policy=TRUE)
> # I defined the appropriate data file and weight file
> summary(fit1)
> library(car)
> plot(fit1)
> # it gives me following error
> Error in plot.window(...) : need finite 'xlim' values
> In addition: Warning messages:
> 1: In min(x) : no non-missing arguments to min; returning Inf
> 2: In max(x) : no non-missing arguments to max; returning -Inf
> 3: In min(x) : no non-missing arguments to min; returning Inf
> 4: In max(x) : no non-missing arguments to max; returning -Inf
> # when I do-
> plot(fit1$fit, fit1$res)
> # it gives the plot of fit1$fit vs. Index ( i guess the observation number)

There is no plot() method for an object of class "sarlm", so you get sent 
to the default method. For what it's worth, you could try:

plot(fit1$lm.target)

which will use the correct method, but disregarding the spatial 
coefficient and using an inappropriate hat matrix. There is a paper by 
Haining describing diagnostic plots for spatial regression models, but 
no-one has implemented them.

Roger

>
> Thank you.
>
> Ram Pandit
>

-- 
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