简体   繁体   中英

Can regression and IDW spatial interpolation be done in one model in R?

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,

Is there a way how to do regression and IDW in one model in R?

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.

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:

  • Theoretical , kriging presents a unified way of treating both the model and the residuals in one go using a linear model and create a prediction, ie linear regression with spatially correlated residuals. In case of a hybrid model, this theoretical frame is not present. Because of this ad hoc nature I would not recommend doing this.
  • Practically , gstat simply does not support doing this in one go.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM