GWRLASSO:A Hybrid Model for Spatial Prediction Through Local Regression

Introduction

****
It employs a hybrid spatial approach to enhance spatial prediction. This approach combines the variable selection capability of LASSO (Least Absolute Shrinkage and Selection Operator) with the Geographically Weighted Regression (GWR) model, effectively capturing spatially varying relationships. The developed hybrid model efficiently selects the relevant variables by using LASSO as the first step; these selected variables are then incorporated into the GWR framework,allowing the estimation of spatially varying regression coefficients at unknown locations and finally it predicts the values of the response variable at unknown test locations, while also considering the spatial heterogeneity present in the data.The developed hybrid spatial model can be useful for spatial modeling, especially in scenarios involving complex spatial patterns and large datasets with multiple predictor variables.

****

# Examples: Variable selection and prediction at unknown test locations using GWRLASSO hybrid spatial model 

# Generation of response variable and predictor variables as well as the locational coordinates 

library(GWRLASSO)
n<- 100
p<- 7
m<-sqrt(n)
id<-seq(1:n)
x<-matrix(runif(n*p), ncol=p)
e<-rnorm(n, mean=0, sd=1)
xy_grid<-expand.grid(c(1:m),c(1:m))
Latitude<-xy_grid[,1]
Longitude<-xy_grid[,2]
B0<-(Latitude+Longitude)/6
B1<-(Latitude/3)
B2<-(Longitude/3)
B3<-(2*Longitude)
B4<-2*(Latitude+Longitude)/6
B5<-(4*Longitude/3)
B6<-2*(Latitude+Longitude)/18
B7<-(4*Longitude/18)
y<-B0+(B1*x[,1])+(B2*x[,2])+(B3*x[,3])+(B4*x[,4])+(B5*x[,5])+(B6*x[,6])+(B7*x[,7])+e
data_sp<-data.frame(y,x,Latitude,Longitude)
head(data_sp)
##            y        X1          X2         X3         X4        X5        X6
## 1 -0.3076557 0.1765169 0.709146687 0.14518162 0.36422835 0.1392433 0.4891544
## 2  2.5993062 0.8148199 0.425109126 0.07566073 0.40005463 0.1268588 0.7331524
## 3  2.5145808 0.2355793 0.967396047 0.10236518 0.92676435 0.9996862 0.1872082
## 4  4.5125332 0.8445001 0.746731765 0.26031724 0.66485238 0.9854649 0.4342132
## 5  4.7308383 0.1094802 0.718183988 0.90636630 0.91707854 0.6764188 0.4175659
## 6  6.0048363 0.7037446 0.005454343 0.51151470 0.06984434 0.7139012 0.7298994
##          X7 Latitude Longitude
## 1 0.1808931        1         1
## 2 0.2063953        2         1
## 3 0.5449305        3         1
## 4 0.5468516        4         1
## 5 0.9154448        5         1
## 6 0.9966209        6         1
# Application of the GWRLASSO model with the exponential kernel function

library(GWRLASSO)
GWRLASSO_exp<-GWRLASSO_exponential(data_sp,0.8,0.7,exponential_kernel,10)
GWRLASSO_exp
## $Important_vars
## [1] "X1" "X3" "X4" "X5" "X6"
## 
## $Optimum_lamda
## [1] 0.5182527
## 
## $GWR_y_pred_test
##  [1]  2.529810  4.474079  4.781577  4.726519  6.211415  6.667198  2.740433
##  [8]  9.915138  9.743077 10.692794 10.348643 12.669678 17.292199 16.727441
## [15] 21.895763 17.123127 28.820731 21.665022 10.516593 21.736282 14.918064
## [22] 22.383313 15.805552 19.931612 23.441323 35.717608 22.655893 32.368199
## [29] 22.201508 31.088042
## 
## $R_square
## [1] 0.9996726
## 
## $rrmse
## [1] 0.01043158
## 
## $mse
## [1] 0.02808344
## 
## $mae
## [1] 0.1209918
# Application of the GWRLASSO model with the gaussian kernel function

library(GWRLASSO)
GWRLASSO_gau<-GWRLASSO_gaussian(data_sp,0.8,0.7,gaussian_kernel,10)
GWRLASSO_gau
## $Important_vars
## [1] "X1" "X2" "X3" "X4" "X5" "X6" "X7"
## 
## $Optimum_lamda
## [1] 0.01235606
## 
## $GWR_y_pred_test
##  [1]  5.265664  5.982710  2.656073  6.865829 10.794079  9.605300 14.269145
##  [8] 17.096948  9.924671 12.126222 19.593007 10.574199 17.813270 24.586074
## [15]  5.118169 13.992486 10.572248 24.189602 13.069569 31.184487 28.405111
## [22] 14.948229 19.711030 23.939771 27.432904 21.754934 22.278007 21.330253
## [29] 25.912041 30.008339
## 
## $R_square
## [1] 0.9999978
## 
## $rrmse
## [1] 0.0007311276
## 
## $mse
## [1] 0.0001491243
## 
## $mae
## [1] 0.005688836