Running geographic weighted regression on subset of data from large raster using spgwr package

272 Views Asked by At

I have a large raster dataset that I have converted to a SpatialPointsDataFrame and from there to a regular data frame. I need to run a geographic weighted regression (GWR) using the spgwr package. I have successfully computed a GWR bandwidth using the gwr.sel() function but when I try run the GWR using gwr() I get an error saying that R cannot allocate a vector of size 25 Gb. I was thinking it may be possible to run the local GWR regression on just a random subsample of the entire data frame while keeping all other points as neighbourhood values for the regression.

Here is what I have so far but I am not sure how to run the GWR on a subsample without getting rid of every other point.

##Calculate kernel bandwidth
gwr.bw <- gwr.sel(merge.df$nsEVI_YAproj ~ merge.df$aDEM_YAproj, data = merge.df, coords = cbind(merge.df$x, merge.df$y), adapt = TRUE)

##Run GWR model
gwr <- gwr(merge$nsEVI_YAproj ~ merge$aDEM_YAproj, data = merge.df, coords = cbind(merge.df$x, merge.df$y), adapt = gwr.bw, hatmatrix = TRUE, se.fit = TRUE)
0

There are 0 best solutions below