gwr {spgwr} | R Documentation |
The function implements the basic geographically weighted regression approach to exploring spatial non-stationarity for given global bandwidth and chosen weighting scheme.
gwr(formula, data=list(), coords, bandwidth, gweight=gwr.gauss, adapt=NULL, hatmatrix = FALSE, fit.points, longlat=FALSE) print.gwr(x, ...)
formula |
regression model formula as in lm |
data |
model data frame, or SpatialPointsDataFrame or SpatialPolygonsDataFrame as defined in package sp |
coords |
matrix of coordinates of points representing the spatial positions of the observations; may be omitted if the object passed through the data argument is from package sp |
bandwidth |
bandwidth used in the weighting function, possibly
calculated by gwr.sel |
gweight |
geographical weighting function, at present only
gwr.gauss() or gwr.bisquare() |
adapt |
either NULL (default) or a proportion between 0 and 1 of observations to include in weighting scheme (k-nearest neighbours) |
hatmatrix |
if TRUE, return the hatmatrix as a component of the result |
fit.points |
an object containing the coordinates of fit points; often an object from package sp; if missing, the coordinates given through the data argument object, or the coords argument are used |
longlat |
if TRUE, use distances on an ellipse with WGS84 parameters |
x |
an object of class "gwr" returned by the gwr function |
... |
arguments to be passed to other functions |
The function applies the weighting function in turn to each of the observations, or fit points if given, calculating a weighted regression for each point. The results may be explored to see if coefficient values vary over space.
SDF |
a SpatialPointsDataFrame (may be gridded) or SpatialPolygonsDataFrame object (see package "sp") with fit.points, weights, GWR coefficient estimates, R-squared, and coefficient standard errors in its "data" slot. |
lhat |
Leung et al. L matrix |
lm |
Ordinary least squares global regression on the same model formula. |
bandwidth |
the bandwidth used. |
this.call |
the function call used. |
Roger Bivand Roger.Bivand@nhh.no
Fotheringham, A.S., Brunsdon, C., and Charlton, M.E., 2002, Geographically Weighted Regression, Chichester: Wiley; http://www.nuim.ie/ncg/GWR/index.htm
gwr.sel
, gwr.gauss
,
gwr.bisquare
data(columbus) col.lm <- lm(crime ~ income + housing, data=columbus) summary(col.lm) col.bw <- gwr.sel(crime ~ income + housing, data=columbus, coords=cbind(columbus$x, columbus$y)) col.gauss <- gwr(crime ~ income + housing, data=columbus, coords=cbind(columbus$x, columbus$y), bandwidth=col.bw, hatmatrix=TRUE) col.gauss col.d <- gwr.sel(crime ~ income + housing, data=columbus, coords=cbind(columbus$x, columbus$y), gweight=gwr.bisquare) col.bisq <- gwr(crime ~ income + housing, data=columbus, coords=cbind(columbus$x, columbus$y), bandwidth=col.d, gweight=gwr.bisquare, hatmatrix=TRUE) col.bisq data(georgia) g.adapt.gauss <- gwr.sel(PctBach ~ TotPop90 + PctRural + PctEld + PctFB + PctPov + PctBlack, data=gSRDF, adapt=TRUE) res.adpt <- gwr(PctBach ~ TotPop90 + PctRural + PctEld + PctFB + PctPov + PctBlack, data=gSRDF, adapt=g.adapt.gauss) res.adpt pairs(as(res.adpt$SDF, "data.frame")[,c(17,18, 1:9)], pch=".") brks <- c(-0.25, 0, 0.01, 0.025, 0.075) cols <- grey(5:2/6) plot(res.adpt$SDF, col=cols[findInterval(res.adpt$SDF$PctBlack, brks, all.inside=TRUE)]) g.bw.gauss <- gwr.sel(PctBach ~ TotPop90 + PctRural + PctEld + PctFB + PctPov + PctBlack, data=gSRDF) res.bw <- gwr(PctBach ~ TotPop90 + PctRural + PctEld + PctFB + PctPov + PctBlack, data=gSRDF, bandwidth=g.bw.gauss) res.bw pairs(as(res.bw$SDF, "data.frame")[,c(17,18, 1:9)], pch=".") plot(res.bw$SDF, col=cols[findInterval(res.bw$SDF$PctBlack, brks, all.inside=TRUE)]) g.bw.gauss <- gwr.sel(PctBach ~ TotPop90 + PctRural + PctEld + PctFB + PctPov + PctBlack, data=gSRDF, longlat=TRUE) if (require(spgpc)) { gSR <- as(gSRDF, "SpatialPolygons") length(getSpPpolygonsSlot(gSR)) gSRouter <- unionSpatialPolygons(gSR, IDs=rep("Georgia", 159)) gGrid <- sample.Polygons(getSpPpolygonsSlot(gSRouter)[[1]], 5000, type="regular") gridded(gGrid) <- TRUE summary(gGrid) res.bw <- gwr(PctBach ~ TotPop90 + PctRural + PctEld + PctFB + PctPov + PctBlack, data=gSRDF, bandwidth=g.bw.gauss, fit.points=gGrid, longlat=TRUE) res.bw spplot(res.bw$SDF, "PctBlack") }