ggwr.sel.Rd
The function finds a bandwidth for a given generalised geographically weighted regression by optimzing a selected function. For cross-validation, this scores the root mean square prediction error for the generalised geographically weighted regressions, choosing the bandwidth minimizing this quantity.
ggwr.sel(formula, data = list(), coords, adapt = FALSE, gweight = gwr.Gauss,
family = gaussian, verbose = TRUE, longlat = NULL, RMSE=FALSE,
tol=.Machine$double.eps^0.25)
regression model formula as in glm
model data frame as in glm
, or may be a SpatialPointsDataFrame or SpatialPolygonsDataFrame object as defined in package sp
matrix of coordinates of points representing the spatial positions of the observations
either TRUE: find the proportion between 0 and 1 of observations to include in weighting scheme (k-nearest neighbours), or FALSE --- find global bandwidth
geographical weighting function, at present
gwr.Gauss()
default, or gwr.gauss()
, the previous default or gwr.bisquare()
a description of the error distribution and link function to
be used in the model, see glm
if TRUE (default), reports the progress of search for bandwidth
TRUE if point coordinates are longitude-latitude decimal degrees, in which case distances are measured in kilometers; if x is a SpatialPoints object, the value is taken from the object itself
default FALSE to correspond with CV scores in newer references (sum of squared CV errors), if TRUE the previous behaviour of scoring by LOO CV RMSE
the desired accuracy to be passed to optimize
returns the cross-validation bandwidth.
Fotheringham, A.S., Brunsdon, C., and Charlton, M.E., 2002, Geographically Weighted Regression, Chichester: Wiley; http://gwr.nuim.ie/
The use of GWR on GLM is only at the initial proof of concept stage, nothing should be treated as an accepted method at this stage.
# \donttest{
if (require(sf)) {
xx <- as(st_read(system.file("shapes/sids.shp", package="spData")[1]), "Spatial")
bw <- ggwr.sel(SID74 ~ I(NWBIR74/BIR74) + offset(log(BIR74)), data=xx,
family=poisson(), longlat=TRUE)
bw
}
#> Reading layer `sids' from data source
#> `/home/rsb/lib/r_libs/spData/shapes/sids.shp' using driver `ESRI Shapefile'
#> Simple feature collection with 100 features and 22 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
#> CRS: NA
#> Bandwidth: 302.9456 CV score: 1204.711
#> Bandwidth: 489.6869 CV score: 1211.156
#> Bandwidth: 187.5331 CV score: 1188.477
#> Bandwidth: 116.2043 CV score: 1197.936
#> Bandwidth: 197.1794 CV score: 1190.679
#> Bandwidth: 166.747 CV score: 1183.541
#> Bandwidth: 147.4414 CV score: 1180.42
#> Bandwidth: 135.5099 CV score: 1181.441
#> Bandwidth: 146.8813 CV score: 1180.393
#> Bandwidth: 145.1043 CV score: 1180.346
#> Bandwidth: 141.4396 CV score: 1180.461
#> Bandwidth: 144.5526 CV score: 1180.344
#> Bandwidth: 144.647 CV score: 1180.343
#> Bandwidth: 144.6561 CV score: 1180.343
#> Bandwidth: 144.6555 CV score: 1180.343
#> Bandwidth: 144.6555 CV score: 1180.343
#> Bandwidth: 144.6554 CV score: 1180.343
#> Bandwidth: 144.6555 CV score: 1180.343
#> [1] 144.6555
# }