GWR


Software Required for Download – QGIS & R

※Applicable Version: QGIS Greater Than 3.16 & R Greater Than 3.0.0

Ⅰ. Introduction

GWR

GWR (Geographically Weighted Regression) is a statistical method used in Geographic Information Science (GIS) to explore spatial data relationships.

In real life, certain phenomena may vary based on geographical location. For instance, housing prices might be influenced by specific factors of the city they are located in. Unlike traditional regression models that assume a fixed relationship between each observation, regardless of spatial location, GWR takes into account the variations in model parameters due to geographical position.

Main Features:

1.Considering Geographical Location: Each geographical location has a regression equation, and the model parameters are allowed to vary spatially.

2.Weight Function: Regression parameters for each location are calculated using geographical weighting, where observations closer to the location have a greater influence on its regression parameters.

3.Model Interpretation: A parameter map can be generated to illustrate how a specific parameter varies with geographical location, aiding in the explanation of spatial variability.

4.Higher Complexity: It contributes to the exploration of spatial variability.The need for this level of complexity should be evaluated, along with ensuring ample data support.


Plugin Advantage

1.User-Friendly

Users only need to install R and the Processing R Provider plugin in QGIS. After copying the relevant program documentation to the specified path, it can be used. If adjustments are needed later on, the program documentation can be directly modified.

2.QGIS Variable Name Truncation Issue

When processing data, QGIS truncates variable names that exceed ten characters. However, in the parameter menu, the original full variable names are retained. Therefore, this procedure also truncates the variable names selected by the user in the manner of QGIS to prevent issues arising from discrepancies between the backend data variables in QGIS and the user's selection. Nevertheless, since QGIS's truncation method is related to the order of the variables, problems may still arise if the user's selected variable order differs from the original data's variable order.

Ⅱ. Installation Procedure


Step 1

Install QGIS & R

Step 2

After opening QGIS, click on 'Plugins' in the top menu, then select 'Manage and install Plugins'.

Step 3

Search for 'Processing R Provider', then click on 'Install Plugin' > 'Close'.

Step 4

After restarting QGIS, click on 'Setting' > 'Options' in the top menu.

Step 5

Click on 'Processing' > 'Providers' > 'R', and set the R folder path (e.g., C:\Program Files\R\R-4.3.1; the actual path may vary depending on the system, version, or directory).

※ If the installed version of R is 64-bit, make sure to check the 'Use 64-bit version' option.

Windows Settings
Mac Settings

Step 6

Open the folder named 'R scripts folder'.

※This folder is used to store GWR or other R program files (the path is under the QGIS installation directory).

Step 7

Add gwr.rsx and gwr.help program files under the R scripts folder directory.

Step 8

Restart QGIS and verify in the Processing ToolBox whether the R category and the GWmodel folder within it have been successfully installed. If you see the Geographical Weighted Regression program within the GWmodel category and it can be opened normally, it indicates the installation is complete.

※ If there's an issue when starting the Geographical Weighted Regression program, the problem might be with the R folder path from Step 2.

Example of Completed Setup

Ⅲ. Steps


Step 1 Import Data

● Import spatial point data or polygon data.

Data input of GWR

● After importing the data, launch the Geographical Weighted Regression process and select the input data in the Layer section.

Data selection for GWR

Step 2 Select Parameters

This section is the primary user interface. Users can select the corresponding parameters and inputs based on their needs, and define the output data path.

Dependent Variable

All variables are single-choice menus, allowing you to select the corresponding response variable according to your needs.

Dependent Variable of GWR

Expanatory Variables

All variables are multiple-choice menus, allowing you to select the corresponding explanatory variables according to your needs.

Dependent Variable of GWR

Selection of Kernel, Approach, and Fixed / Adaptive

Selecting the parameters for calculating bandwidth and the parameters for the subsequent model.

○ List of Kernel Functions – Gaussian, Exponential, Bisquare, Tricube, and Boxcar.

List of GWR kernel function

○ List of GWR Approach – CV, AIC, AICc, and BIC.

List of GWR approach

○ Fixed or Adaptive bandwidth

Fixed or Adaptive bandwidth

Selection of Other Parameters

All have default values and can be adjusted according to the situation.

Other parameter selections for GWR

Output Data Path ( Floder Path )

Specify the data output path.

Output data path of GWR

Step 3 Output Results

Document Output

During the QGIS process, two main types of data are primarily output:

1. Scores for Different Bandwidths: Due to the selection of fixed bandwidth in the parameters and the choice based on CV scores, the output results will have different bandwidths and their corresponding scores (see lower left figure).

2. Model Results: You can view the basic information of the model (see lower right figure). This content will be simultaneously output as a document to the user's specified output path.

Output of GWR QGIS Bandwidth
Output of GWR result

Data Output

1. When completing the procedure, a 'GWR_result' folder will be created in the path specified by the user (see lower left figure). This folder contains two main components:

1. "GWR_result.txt": Information document of the model (refer to the lower right figure).

2. Model output is in Shapefile format: It includes four files - 'GWR_result.shp', 'GWR_result.shx', 'GWR_result.dbf', and 'GWR_result.prj'. If users want to utilize these files, they can import the 'GWR_result.shp' file into QGIS (see lower right figure). After the process is completed, QGIS will add a new 'Output' layer, with content identical to that of the 'GWR_result.shp' file, both representing the model's output result.

Model output data
Contents of the GTWR Result folder

For more information, you can refer the following:

[1] Chan, T. C., Chiang, P. H., Su, M. D., Wang, H. W., & Liu, M. S. Y. (2014). Geographic disparity in chronic obstructive pulmonary disease (COPD) mortality rates among the Taiwan population. PloS one, 9(5), e98170.

[2] Fotheringham, A. S., Crespo, R., & Yao, J. (2015). Geographical and temporal weighted regression (GTWR). Geographical Analysis, 47(4), 431-452.

[3] Nugroho, W. H., & Sumarminingsih, E. (2021, March). Geographically and Temporally Weighted Regression Model with Gaussian Kernel Weighted Function and Bisquare Kernel Weighted Function. In IOP Conference Series: Materials Science and Engineering (Vol. 1115, No. 1, p. 012063). IOP Publishing.

[4] Wu, B., Li, R., & Huang, B. (2014). A geographically and temporally weighted autoregressive model with application to housing prices. International Journal of Geographical Information Science, 28(5), 1186-1204.