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 2.631188 0.23019905 0.34038391 0.9131724 0.41327834 0.67240829 0.6118471
## 2 1.432850 0.32057670 0.95436802 0.2761544 0.12421239 0.17039480 0.8041488
## 3 3.553465 0.01488057 0.55857220 0.5485743 0.09433316 0.96437613 0.5807104
## 4 4.141245 0.07812533 0.74821847 0.3596221 0.20927917 0.37994810 0.7181108
## 5 4.650488 0.76195004 0.15137767 0.3791145 0.47117752 0.64333798 0.3162779
## 6 4.787636 0.61399981 0.02700061 0.5737010 0.03861767 0.02813304 0.1157245
##          X7 Latitude Longitude
## 1 0.2367224        1         1
## 2 0.3631240        2         1
## 3 0.6146041        3         1
## 4 0.3063895        4         1
## 5 0.7534566        5         1
## 6 0.1693458        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" "X2" "X3" "X4" "X5" "X6" "X7"
## 
## $Optimum_lamda
## [1] 0.01219669
## 
## $GWR_y_pred_test
##  [1]  2.639668  3.523615  4.883019  8.847180 10.097140 10.073321  7.576522
##  [8] 10.912350  7.692422  8.782824 15.897758 12.918609 10.485054  7.077202
## [15] 13.534255 14.657082 14.027363  8.735348 10.053202 27.952096 31.929890
## [22] 18.938981 26.667354 30.818859 32.882654 17.459992 14.395213 40.462473
## [29] 27.374481 36.222636
## 
## $R_square
## [1] 0.9998895
## 
## $rrmse
## [1] 0.006675323
## 
## $mse
## [1] 0.01175841
## 
## $mae
## [1] 0.07138861
# 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.01565076
## 
## $GWR_y_pred_test
##  [1]  1.435136  3.593077  4.040649  4.649345  4.787733  4.777420  9.423779
##  [8]  3.763945  7.565162  8.742363  8.941288  7.574054  8.862612  7.649115
## [15] 12.637254  7.113208 13.549672 13.567847 15.081165 11.693229 10.067515
## [22] 24.955346 18.960325 26.582824 17.514127 23.941561 19.771420 12.758013
## [29] 35.203101 14.294951
## 
## $R_square
## [1] 0.9999925
## 
## $rrmse
## [1] 0.001790336
## 
## $mse
## [1] 0.0004708506
## 
## $mae
## [1] 0.007424902