This repository contains a Shiny application designed for visualizing the concept of Geographically Weighted Regression (GWR) in an interactive 3D environment. The app is intended as an educational tool, helping users understand how GWR models vary across geographic space by allowing them to interactively explore the results of GWR analyses on spatial data.
The following image shows a snapshot of the Shinyapp in action:
You can visit and try the application from here.
-
3D Visualization: Explore spatial data and GWR results in a 3D environment using
plotly
. -
Interactive Bandwidth Adjustment: Dynamically adjust the bandwidth parameter to see how it influences the GWR model, providing a deeper understanding of spatial heterogeneity.
-
Model Comparison: Compare the GWR model results with a global Ordinary Least Squares (OLS) regression model to highlight the advantages of GWR in capturing local variations.
-
Help & Tutorials: Built-in help and tutorials guide users through the features of the app and the key concepts behind GWR.
Make sure you have R and RStudio installed on your machine. You'll also need to install the following R packages:
install.packages(c("shiny", "plotly", "spgwr", "sp", "spdep", "RColorBrewer"))
To get started, clone this repository to your local machine:
git clone https://github.com/mohammedyounes98/GWR_Viz.git
cd GWR_Viz
To run the app locally:
-
Open the
GWR_Viz.R
file in RStudio. -
Click the "Run App" button, or use the following command in your R console:
shiny::runApp("GWR_Viz.R")
The app should open in a new window or in your default web browser.
-
Bandwidth Slider: Use this slider to adjust the bandwidth parameter. Smaller bandwidth values result in more localized models, while larger bandwidths approach global regression.
-
View Type Selector: Choose between viewing raw data, GWR results, or a comparison between GWR and OLS models.
-
Help & Tutorial: Access a step-by-step guide on how to use the app and understand the GWR analysis.
The app includes a dedicated "Interpretation" tab to help users understand the GWR results. Key points include:
-
Coefficient Values: Show the strength and direction of relationships between variables at each location.
-
Varying Coefficients: Capture how these relationships change across space.
-
T-values: Indicate the statistical significance of local relationships.
The app generates a sample dataset when it starts. You can modify the data generation process in the app.R
file if you want to experiment with different spatial datasets.
Contributions are welcome! If you have any suggestions for improvements or find any bugs, feel free to open an issue or submit a pull request.
-
Fork the repository.
-
Create a new branch:
git checkout -b my-feature-branch
-
Make your changes and commit them:
git commit -m 'Add some feature'
-
Push to the branch:
git push origin my-feature-branch
-
Submit a pull request.
This project is licensed under the GNU License. See the LICENSE file for details.
-
The GWR model implementation uses the
spgwr
package by Roger Bivand. -
The interactive plots are powered by
plotly
.