[GIS] Moving window regression (MWR) in R

modellingr

I'm looking for some package in R to estimate the value of a variable by moving window regression. I have read in Local Models for Spatial Analysis, which is a good method to predict values ​​at unsampled locations. A very similar case is mentioned in the book, PRISM.

I've been reading various R packages, but have not found anything about MWR, GWR only.

Is there another way of naming or can GWR be adapted to function as MWR?

Text from book ->
Local Models for Spatial Analysis

Best Answer

I don't see any equations in the section in Lloyd that you linked to, but it seems from the description that MWR is similar to GWR except that it's on a grid (always, or just in this example?), and that it always uses a fixed bandwidth and a fixed or inverse-distance weighted kernel. If this is correct, I think you can accomplish what you want by using GWR and specifying the weighting function yourself instead of using the built-in functions (gwr.gauss, gwr. bilinear).

In the gwr function call, set the bandwidth argument to the desired radius of the moving window, in the units of your spatial object (will depend on the projection), and set the gweight argument as follows:

gwr(..., gweight = function(a, b) 1, ...)

This function will return a weight of 1 for all point pairs in the local regressions, which is the simplest version described in source you linked to. (Note that a and b are arbitrary parameter names, internally gwr uses dxs for the first (distance) parameter and bandwidthR2 for the second (bandwidth) parameter.) Make sure to specify the fit.points argument using a SpatialPointsDataFrame (or other object of xy coordinates) of the points that you want to predict. If your data is gridded, you will also have to convert to a SpatialPointsDataFrame for the data argument. This can be accomplished with:

gridded(yourGrid) = FALSE

This works for SpatialGridDataFrame or SpatialPixelsDataFrame, you may have to do something different if you're using the raster package.

Related Question