gwr.est: Geographically weighted regression

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/gwr.est.R

Description

This function fits a geographically weighted regression (GWR) model

Usage

1
gwr.est(form, locs, data, kernel = "exp", bw = TRUE, cv.tol)

Arguments

form

A regression model forumula, as in the functions lm and glm

locs

A matrix of spatial coordinates of data points, where the x coordinate is first, then the y coordinate; coordinates are assumed to not be latitude and longitude, as Euclidean distance is calculated from coordinates

data

A data frame with data to fit model

kernel

A kernel weighting function, either exp or gauss, where exponential function is default

bw

Either TRUE to estimate a bandwidth for the kernel function, or the bandwidth to use to fit the model; bandwidth is estimated by default

cv.tol

A stopping tolerance in terms of cross-validation error for the bi-section search routine to estimate the kernel bandwidth using cross-validation; if missing an internally calculated value is used

Details

This function estimates spatially varying coefficients using the GWR approach. Spatial kernel weights are applied to observations using the estimated or supplied kernel bandwidth to estimate local models at each data point. The bandwidth is currently estimated with cross-validation with an exponential or Gaussian kernel function. The function estimates regression coefficients, the outcome variable values, and the model fit.

Value

A list with the following items:

phi

Kernel bandwidth

RMSPE

Root mean squared prediction error from bandwidth estimation

beta

Matrix of estimated regression coefficients, where a row contains the coefficients for one regression term for all data points

yhat

Estimated outcome variable values

RMSE

Root mean squared error from estimation

rsquare

Approximate R-square for GWR model

Author(s)

David Wheeler

References

Wheeler DC (2007) Diagnostic tools and a remedial method for collinearity in geographically weighted regression. Environment and Planning A, 39: 2464-2481

See Also

gwr.bw.est

Examples

1
2
3
4
5
data(columbus)
locs <- cbind(columbus$x, columbus$y)
col.gwr <- gwr.est(crime ~ income + houseval, locs, columbus, "exp")
plot(col.gwr$beta[2,], col.gwr$beta[3,])
plot(columbus$x, columbus$y, cex=col.gwr$beta[1,]/10)

Example output

Loading required package: fields
Loading required package: spam
Loading required package: dotCall64
Loading required package: grid
Spam version 2.1-1 (2017-07-02) is loaded.
Type 'help( Spam)' or 'demo( spam)' for a short introduction 
and overview of this package.
Help for individual functions is also obtained by adding the
suffix '.spam' to the function name, e.g. 'help( chol.spam)'.

Attaching package: 'spam'

The following objects are masked from 'package:base':

    backsolve, forwardsolve

Loading required package: maps
Loading required package: lars
Loaded lars 1.2

[1] "Bandwidth:  21.07  RMSPE : 12.21"
[1] "Bandwidth:  15.87  RMSPE : 12.16"
[1] "Bandwidth:  11.97  RMSPE : 12.1"
[1] "Bandwidth:  9.051  RMSPE : 12.02"
[1] "Bandwidth:  6.858  RMSPE : 11.94"
[1] "Bandwidth:  5.214  RMSPE : 11.86"
[1] "Bandwidth:  3.98  RMSPE : 11.81"
[1] "Bandwidth:  3.055  RMSPE : 11.74"
[1] "Bandwidth:  2.361  RMSPE : 11.59"
[1] "Bandwidth:  0.8003  RMSPE : 11.68"
[1] "Bandwidth:  1.971  RMSPE : 11.41"
[1] "Bandwidth:  1.678  RMSPE : 11.24"
[1] "Bandwidth:  1.02  RMSPE : 11.19"
[1] "Bandwidth:  1.514  RMSPE : 11.14"
[1] "Bandwidth:  1.267  RMSPE : 11.07"

gwrr documentation built on May 2, 2019, 7:07 a.m.