Skip to content

using gwr for interpolation

4 messages · Edzer Pebesma, Torleif Markussen Lunde, Roger Bivand

#
Can I use gwr for interpolation?

I would for example use something like

library(spgwr)
data(meuse)
coordinates(meuse) = ~x+y
data(meuse.grid)
gridded(meuse.grid) = ~x+y
x = gwr(cadmium ~ dist, meuse, bandwidth = 228, fit.points = meuse.grid)
spplot(x$SDF["gwr.e"])

But it doesn't give what I'd expected - somehow nicely interpolated
cadmium values. I probably misused fit.points, but I couldn't see any
predict method. Is this possible at all?
#
Hi

I think the error is in .GWR_int line 42:
df[i, (m + 3)] <- ei[i]

ei will have length equal to dim(data)[1], while i is equal to 
nrow(fit.points). So as i > dim(data)[1] ei[i] will be NA. 

This could explain why only the first 155 points are evaluated (in your 
example).

Best wishes
Torleif
On Friday 29 May 2009 11:36:08 am Edzer Pebesma wrote:
#
On Fri, 29 May 2009, Edzer Pebesma wrote:

            
Since GWR was created to look at *coefficient* variability, prediction 
isn't a natural, and fit.points are assumed just to be points, not points 
with attributes; there is nothing in Forthingham et al. (2002) about 
prediction. So:

spplot(x$SDF, "dist")
fortune("Yoda")
gwrcoefs <- as.matrix(as(x$SDF, "data.frame")[,2:3])
X <- model.matrix( ~ dist, meuse.grid)
meuse.grid$pred <- apply(gwrcoefs * X, 1, sum)
spplot(meuse.grid, "pred")

It could be written into gwr(), or as a predict() method, but that might 
require changes in the gwr object to make sure that the predicted 
attribute values were properly keyed to the fit point locations. To get 
standard errors, you'd need to store more of the objects returned by 
lm.wfit() for each fit point, which could be done, but should it?

Hope this helps,

Roger

  
    
#
On Fri, 29 May 2009, Torleif Markussen Lunde wrote:

            
Right, thanks. Residuals are only defined when the fit points are the same 
as the data points - when fit points are given, NA should be returned.

Roger