Learn R Programming

spgwr (version 0.5-7)

ggwr.sel: Crossvalidation of bandwidth for generalised GWR

Description

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.

Usage

ggwr.sel(formula, data = list(), coords, adapt = FALSE, gweight = gwr.Gauss,
 family = gaussian, verbose = TRUE, longlat = FALSE, RMSE=FALSE)

Arguments

formula
regression model formula as in glm
data
model data frame as in glm, or may be a SpatialPointsDataFrame or SpatialPolygonsDataFrame object as defined in package sp
coords
matrix of coordinates of points representing the spatial positions of the observations
adapt
either TRUE: find the proportion between 0 and 1 of observations to include in weighting scheme (k-nearest neighbours), or FALSE --- find global bandwidth
gweight
geographical weighting function, at present gwr.Gauss() default, or gwr.gauss(), the previous default or gwr.bisquare()
family
a description of the error distribution and link function to be used in the model, see glm
verbose
if TRUE (default), reports the progress of search for bandwidth
longlat
if TRUE, use distances on an ellipse with WGS84 parameters
RMSE
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

Value

  • returns the cross-validation bandwidth.

References

Fotheringham, A.S., Brunsdon, C., and Charlton, M.E., 2002, Geographically Weighted Regression, Chichester: Wiley; http://www.nuim.ie/ncg/GWR/index.htm

See Also

gwr.sel, ggwr

Examples

Run this code
library(maptools)
xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], 
  IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
bw <- ggwr.sel(SID74 ~ I(NWBIR74/BIR74) + offset(log(BIR74)), data=xx,
  family=poisson(), longlat=TRUE)
bw

Run the code above in your browser using DataLab