A modern, sf-first implementation of Geographically Weighted Panel
Regression (GWPR) for spatial panel data. Version 1.0.0 provides a
clean public API, three bandwidth search strategies (grid, SGD, random),
Gaussian and binomial model families, and optional parallel execution
via the future framework.
Chao Li chaoli0394@gmail.com
Shunsuke Managi managi@doc.kyushu-u.ac.jp
Install the released version from CRAN:
install.packages("GWPR.light")Or install the development version from GitHub:
# install.packages("remotes")
remotes::install_github("MichaelChaoLi-cpu/GWPR.light")The four public functions form the complete interface:
library(GWPR.light)
library(sf)
# --- Simulate a small spatial panel ---
set.seed(1)
pts <- sf::st_as_sf(
data.frame(id = 1:6, X = c(0,1,2,0,1,2), Y = c(0,0,0,1,1,1)),
coords = c("X", "Y"), crs = NA_integer_
)
dat <- data.frame(
id = rep(1:6, each = 4),
time = rep(1:4, 6),
x1 = rnorm(24),
x2 = rnorm(24)
)
dat$y <- 1.5 * dat$x1 - 0.8 * dat$x2 + rnorm(24, sd = 0.3)
# --- Fit with a known bandwidth ---
fit <- fit_gwpr(
y ~ x1 + x2, data = dat, spatial = pts,
id = "id", time = "time",
bandwidth = 2, model = "pooling", workers = 1
)
print(fit)bw <- select_bandwidth(
y ~ x1 + x2, data = dat, spatial = pts,
id = "id", time = "time",
method = "grid",
control = list(lower = 0.5, upper = 3, step = 0.5),
workers = 1
)
cat("Optimal bandwidth:", bw$best_bandwidth, "\n")diag_result <- diagnose_gwpr(fit, diagnostics = c("f_test", "hausman"))
print(diag_result)vignette("gwpr-introduction")— Getting started with the 1.0.0 APIvignette("introduction_of_GWPR")— Legacy 0.2.x API reference
- Fotheringham, A., Brunsdon, C., Charlton, M. (2002). Geographically Weighted Regression. John Wiley & Sons. ISBN: 978-0-470-85525-6.
- Beenstock, M., Felsenstein, D. (2019). The Econometric Analysis of Non-Stationary Spatial Panel Data. Springer. ISBN: 978-3-030-03614-0.
