Skip to contents

mgwrfit fits MGWR (Fotheringham, Yang and Kang 2017) by backfitting from OLS (intercept prepended when X has no constant column, predictors not centred) with covariate-specific bandwidths, fixed or re-selected at each pass by golden-section minimisation of the one-covariate AICc (mgwrbw), and tracks the covariate-specific hat matrices for inference (Yu et al. 2020): standard errors, ENP, tr S, sigma^2 = RSS/(n - tr S) and AICc. mgwrcof, mgwrres, mgwrstd, mgwrhat return its coefficients, residuals, standard errors and hat diagonal; mgwrcv the leave-one-out score sum (e_i/(1 - S_ii))^2; mgwrbk runs the backfitting with fixed bandwidths; mgwraic, mgwrdg and mgwrsig the AICc, diagnostic summary and error variance from ll, tr S and the residuals; mgwrtst the Monte Carlo test of coefficient variability with Philox permutations.

Usage

mgwrfit(
  y,
  X,
  coords,
  bandwidths = NULL,
  kernel = "bisquare",
  adaptive = FALSE,
  threshold = 1e-10,
  max_iter = 500
)

mgwrcof(y, X, coords, bws = NULL, kernel = "bisquare", adaptive = FALSE)

mgwrres(y, X, coords, bws = NULL, kernel = "bisquare", adaptive = FALSE)

mgwrstd(y, X, coords, bws = NULL, kernel = "bisquare", adaptive = FALSE)

mgwrhat(y, X, coords, bws = NULL, kernel = "bisquare", adaptive = FALSE)

mgwrcv(y, X, coords, bws = NULL, kernel = "bisquare", adaptive = FALSE)

mgwrbw(
  y,
  X,
  coords,
  kernel = "bisquare",
  adaptive = FALSE,
  threshold = 1e-08,
  max_iter = 200
)

mgwrbk(
  y,
  X,
  coords,
  bandwidths,
  max_iter = 10,
  kernel = "bisquare",
  adaptive = FALSE,
  threshold = 1e-10
)

mgwraic(ll, tr_S, n)

mgwrdg(ll, tr_S, n, k = NULL, alpha = 0.05)

mgwrsig(resid, tr_S, n = NULL)

mgwrtst(
  y,
  X,
  coords,
  nsim = 9,
  bandwidths = NULL,
  seed = 0,
  kernel = "bisquare",
  adaptive = FALSE,
  threshold = 1e-08,
  max_iter = 500
)

Arguments

y

Response.

X

Regressors.

coords

Coordinates.

bandwidths, bws

Per-covariate bandwidths (intercept first); NULL selects them.

kernel

Kernel name (see GWRKernelWeights).

adaptive

Adaptive bandwidths.

threshold

Convergence threshold of the backfitting.

max_iter

Maximum number of backfitting passes.

ll

Gaussian log-likelihood.

tr_S

Trace of the hat matrix.

n

Number of observations.

k

Number of covariates (for the corrected test level).

alpha

Nominal level.

resid

Residuals.

nsim

Number of permutations.

seed

Philox seed.

Value

mgwrfit a list with betas, se, fitted, residuals, hat_diagonal, enp, trS, rss, sigma2, aicc, bandwidths, iterations; the others the corresponding parts.

References

Fotheringham, A. S., Yang, W. and Kang, W. (2017). Multiscale geographically weighted regression (MGWR). Annals of the American Association of Geographers 107, 1247-1265. Yu, H., Fotheringham, A. S., Li, Z., Oshan, T., Kang, W. and Wolf, L. J. (2020). Inference in multiscale geographically weighted regression. Geographical Analysis 52, 87-106. Hurvich, C. M., Simonoff, J. S. and Tsai, C.-L. (1998). Smoothing parameter selection in nonparametric regression using an improved Akaike information criterion. JRSS B 60, 271-293. da Silva, A. R. and Fotheringham, A. S. (2016). The multiple testing issue in geographically weighted regression. Geographical Analysis 48, 233-247.

Examples

P <- cbind((0:19) %% 5, (0:19) %/% 5)
X <- cbind(sin(0:19), (0.3 * (0:19)) %% 1.1)
y <- 1 + (1 + 0.2 * P[, 1]) * X[, 1] - X[, 2] + 0.1 * cos(3 * (0:19))
mgwrfit(y, X, P, bandwidths = c(6, 3, 8), kernel = "gaussian")$trS
#> [1] 3.405013
mgwraic(-20, 5.5, 40)$statistic
#> [1] 56