Title: | A Hybrid Spatial Model for Prediction and Capturing Spatial Variation in the Data |
---|---|
Description: | It is a hybrid spatial model that combines the variable selection capabilities of stepwise regression methods with the predictive power of the Geographically Weighted Regression(GWR) model.The developed hybrid model follows a two-step approach where the stepwise variable selection method is applied first to identify the subset of predictors that have the most significant impact on the response variable, and then a GWR model is fitted using those selected variables for spatial prediction at test or unknown locations. For method details,see Leung, Y., Mei, C. L. and Zhang, W. X. (2000).<DOI:10.1068/a3162>.This hybrid spatial model aims to improve the accuracy and interpretability of GWR predictions by selecting a subset of relevant variables through a stepwise selection process.This approach is particularly useful for modeling spatially varying relationships and improving the accuracy of spatial predictions. |
Authors: | Nobin Chandra Paul [aut, cre, cph], Moumita Baishya [aut] |
Maintainer: | Nobin Chandra Paul <[email protected]> |
License: | GPL (>= 2.0) |
Version: | 0.1.0 |
Built: | 2024-11-28 06:30:01 UTC |
Source: | CRAN |
StepGWR: a hybrid spatial model that combines the variable selection capabilities of stepwise regression with the predictive power of Geographically Weighted Regression (GWR) model
StepGWR_exponential(data_sp, bw, split_value, exponential_kernel)
StepGWR_exponential(data_sp, bw, split_value, exponential_kernel)
data_sp |
A dataframe containing a response variable and the predictor variables, as well as the coordinates of the locations. In the dataframe, first column is the response variable (y), last two columns are coordinates i.e., Latitude and Longitudes and in between them is the set of predictor variables(X's). |
bw |
A numeric value specifying the bandwidth parameter for the GWR model. It can be noted that, optimum bandwidth parameter value can vary and depends on the spatial pattern of the dataset. |
split_value |
Splitting value for dividing the dataset into training and testing set, e.g. 0.8 or 0.7 |
exponential_kernel |
Spatial weight function of the GWR model, e.g. exponential_kernel |
A list with the following components: - 'Important_vars ': Selected important variables based on stepwise regression - 'GWR_y_pred_test': The predicted values based on GWR at test locations - 'rrmse': root means square error - 'R_squared': R square value - 'mse': mean squared error - 'mae': mean absolute error
1. Leung, Y., Mei, C. L. and Zhang, W. X. (2000). Statistical tests for spatial non-stationarity based on the geographically weighted regression model. Environment and Planning A, 32(1),9-32.<DOI:10.1068/a3162>. 2. Brunsdon, C., Fotheringham, A.S. and Charlton, M,E. (1996).Geographically weighted regression: a method for exploring spatial non-stationarity. Geogr Anal.28(4),281-298.<DOI:10.1111/j.1538-4632.1996.tb00936.x>.
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) StepGWR_exp<-StepGWR_exponential(data_sp,0.5,0.8,exponential_kernel)
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) StepGWR_exp<-StepGWR_exponential(data_sp,0.5,0.8,exponential_kernel)
StepGWR: a hybrid spatial model that combines the variable selection capabilities of stepwise regression with the predictive power of Geographically Weighted Regression (GWR) model
StepGWR_gaussian(data_sp, bw, split_value, gaussian_kernel)
StepGWR_gaussian(data_sp, bw, split_value, gaussian_kernel)
data_sp |
A dataframe containing a response variable and the predictor variables, as well as the coordinates of the locations. In the dataframe, first column is the response variable (y), last two columns are coordinates i.e., Latitude and Longitudes and in between them is the set of predictor variables(X's). |
bw |
A numeric value specifying the bandwidth parameter for the GWR model. It can be noted that, optimum bandwidth parameter value can vary and depends on the spatial pattern of the dataset. |
split_value |
Splitting value for dividing the dataset into training and testing set, e.g. 0.8 or 0.7 |
gaussian_kernel |
Spatial weight function of the GWR model, e.g. gaussian_kernel |
A list with the following components: - 'Important_vars ': Selected important variables based on stepwise regression - 'GWR_y_pred_test': The predicted values based on GWR at test locations - 'rrmse': root means square error - 'R_squared': R square value - 'mse': mean squared error - 'mae': mean absolute error
1. Leung, Y., Mei, C. L. and Zhang, W. X. (2000). Statistical tests for spatial non-stationarity based on the geographically weighted regression model. Environment and Planning A, 32(1),9-32.<DOI:10.1068/a3162>. 2. Brunsdon, C., Fotheringham, A.S. and Charlton, M,E. (1996).Geographically weighted regression: a method for exploring spatial non-stationarity. Geogr Anal.28(4),281-298.<DOI:10.1111/j.1538-4632.1996.tb00936.x>.
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) StepGWR_gau<-StepGWR_gaussian(data_sp,0.8,0.7,gaussian_kernel)
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) StepGWR_gau<-StepGWR_gaussian(data_sp,0.8,0.7,gaussian_kernel)