Reputation: 59445
I do spatial modelling of variable T (temperature). I use what is commonly used in literature - perform regression (using variables like altitude etc.) and then spatially interpolate the residuals using IDW. R package gstat seems to have this option:
interpolated <- idw(T ~ altitude, stations, grid, idp=6)
spplot(interpolated["var1.pred"])
But in the documentation of idw()
they write:
Function idw performs [...] . Don't use with predictors in the formula.
And actually, the result looks exactly like if only regression was performed, without spatial interpolation of the residuals. I know I can do it manually:
m1 <- lm(T ~ altitude, data = data.frame(stations))
Tres <- resid(m1)
res.int <- idw(Tres ~ 1, stations, grid, idp=6)
Tpred <- predict.lm(m1, grid)
spplot(SpatialGridDataFrame(grid, data.frame(T = Tpred + data.frame(res.int)['var1.pred'])))
But this have many drawbacks - the model is not in one object, so you cannot directly do summary, check for deviance, residuals and most importantly, do crossvalidation... everything will have to be done manually. So,
Note that I don't want to use different method of spatial interpolation, because IDW is used in this area of modelling and was well tested for these purposes.
Upvotes: 1
Views: 1146
Reputation: 60924
So what you want is to do regression first, and then perform IDW on the residuals. This cannot be done in one go, both from a theoretical and a software point of view:
I'd recommend simply going for kriging, which is a very well established and published method. If this has not been used much in your area of expertise, this is a good time to introduce it. You could also have a look at the Tps
function in the fields
package.
Some years back I wrote a technical report for the Dutch Meteorological Office which might be of interest to you, it deals with the interpolation of evaporation.
Upvotes: 2