To address possible local collinearity problems in basic GWR, GWR-LCR finds local ridge parameters at affected
locations (set by a user-specified threshold for the design matrix condition number).
a Spatial*DataFrame, i.e. SpatialPointsDataFrame or SpatialPolygonsDataFrame as defined in package sp
regression.points
a Spatial*DataFrame object, i.e. SpatialPointsDataFrame
or SpatialPolygonsDataFrame as defined in package sp,
or a two-column numeric array
bw
bandwidth used in the weighting function, possibly calculated by bw.gwr.lcr;
fixed (distance) or adaptive bandwidth(number of nearest neighbours)
kernel
function chosen as follows:
gaussian: wgt = exp(-.5*(vdist/bw)^2);
exponential: wgt = exp(-vdist/bw);
bisquare: wgt = (1-(vdist/bw)^2)^2 if vdist < bw, wgt=0 otherwise;
tricube: wgt = (1-(vdist/bw)^3)^3 if vdist < bw, wgt=0 otherwise;
boxcar: wgt=1 if dist < bw, wgt=0 otherwise
p
the power of the Minkowski distance, default is 2, i.e. the Euclidean distance
lambda
option for a globally-defined (constant) ridge parameter. Default is lambda=0, which gives a basic GWR fit
lambda.adjust
a locally-varying ridge parameter. Default FALSE, refers to: (i) a basic GWR without
a local ridge adjustment (i.e. lambda=0, everywhere); or (ii) a penalised GWR with a global ridge adjustment
(i.e. lambda is user-specified as some constant, other than 0 everywhere); if TRUE, use cn.tresh
to set the maximum condition number. Here for locations with a condition number (for its local design matrix)
above this user-specified threshold, a local ridge parameter is found
cn.thresh
maximum value for condition number, commonly set between 20 and 30
adaptive
if TRUE calculate an adaptive kernel where the bandwidth (bw) corresponds to the number of nearest neighbours (i.e. adaptive distance); default is FALSE, where a fixed kernel is found (bandwidth is a fixed distance)
theta
an angle in radians to rotate the coordinate system, default is 0
longlat
if TRUE, great circle distances will be calculated
cv
if TRUE, 'cross-validation data will be calculated and returned in the output Spatial*DataFrame
dMat
a pre-specified distance matrix, it can be calculated by the function gw.dist
Value
A list of class “rgwr”:
SDF
a SpatialPointsDataFrame (may be gridded) or SpatialPolygonsDataFrame object
(see package "sp") with coordinates of regression.points in its "data" slot.
GW.arguments
parameters used for the LCR-GWR calibration
GW.diagnostic
diagnostic information is given when data points are also used as regression locations
Wheeler D (2007) Diagnostic tools and a remedial method for collinearity in geographically weighted regression. Environment and Planning A 39:2464-2481
Brunsdon C, Charlton M, Harris P (2012) Living with collinearity in Local Regression Models. GISRUK 2012, Lancaster, UK
Brunsdon C, Charlton M, Harris P (2012) Living with collinearity in Local Regression Models. Spatial Accuracy 2012, Brazil
Gollini I, Lu B, Charlton M, Brunsdon C, Harris P (2015) GWmodel: an R Package for
exploring Spatial Heterogeneity using Geographically Weighted Models. Journal of
Statistical Software 63(17): 1-50
Examples
data(DubVoter)
require(RColorBrewer)
# Function to find the global condition number (CN)
BKW_cn <- function (X) {
p <- dim(X)[2]
Xscale <- sweep(X, 2, sqrt(colSums(X^2)), "/")
Xsvd <- svd(Xscale)$d
cn <- Xsvd[1] / Xsvd[p]
cn
}
#
X <- cbind(1,Dub.voter@data[,3:10])
head(X)
CN.global <- BKW_cn(X)
CN.global
## Not run:
# gwr.lcr function with a global bandwidth to check that the global CN is found
gwr.lcr1 <- gwr.lcr(GenEl2004~DiffAdd+LARent+SC1+Unempl+LowEduc+Age18_24
+Age25_44+Age45_64, data=Dub.voter, bw=10000000000)
summary(gwr.lcr1$SDF$Local_CN)
# Find and map the local CNs from a basic GWR fit using the lcr-gwr function
#(note this is NOT the locally-compensated ridge GWR fit as would need to set
#lambda.adjust=TRUE and cn.thresh=30, say)
bw.lcr2 <- bw.gwr.lcr(GenEl2004~DiffAdd+LARent+SC1+Unempl+LowEduc+Age18_24
+Age25_44+Age45_64, data=Dub.voter, kernel="bisquare", adaptive=TRUE)
gwr.lcr2 <- gwr.lcr(GenEl2004~DiffAdd+LARent+SC1+Unempl+LowEduc+Age18_24
+Age25_44+Age45_64, data=Dub.voter, bw=bw.lcr2, kernel="bisquare", adaptive=TRUE)
if(require("RColorBrewer"))
spplot(gwr.lcr2$SDF,"Local_CN",col.regions=brewer.pal(9,"YlOrRd"),cuts=8,
main="Local CN")
## End(Not run)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(GWmodel)
Loading required package: maptools
Loading required package: sp
Checking rgeos availability: TRUE
Loading required package: robustbase
Welcome to GWmodel version 1.2-5.
Note: The default kernel for all the functions have been set as bisquare from this release
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GWmodel/gwr.lcr.rd_%03d_medium.png", width=480, height=480)
> ### Name: gwr.lcr
> ### Title: GWR with a locally-compensated ridge term
> ### Aliases: gwr.lcr ridge.lm
> ### Keywords: ridge, GWR
>
> ### ** Examples
>
> data(DubVoter)
> require(RColorBrewer)
Loading required package: RColorBrewer
>
> # Function to find the global condition number (CN)
> BKW_cn <- function (X) {
+ p <- dim(X)[2]
+ Xscale <- sweep(X, 2, sqrt(colSums(X^2)), "/")
+ Xsvd <- svd(Xscale)$d
+ cn <- Xsvd[1] / Xsvd[p]
+ cn
+ }
> #
> X <- cbind(1,Dub.voter@data[,3:10])
> head(X)
1 Y DiffAdd LARent SC1 Unempl LowEduc Age18_24 Age25_44
0 1 235244.0 22.08633 16.208791 8.561151 8.009709 0.600000 24.17266 39.56835
1 1 234933.8 23.59987 22.388060 7.898996 12.126156 0.585586 21.88411 45.48398
2 1 234162.9 33.51579 75.438596 10.610526 8.940201 0.522648 28.04210 49.68421
3 1 234506.9 13.95918 37.298637 5.469388 15.185602 0.698758 14.66667 39.29252
4 1 234737.3 13.88697 13.615870 6.960717 13.021807 0.579581 11.95727 38.04273
5 1 236758.4 6.49846 1.668255 6.043714 2.882353 0.193632 11.88206 33.87120
> CN.global <- BKW_cn(X)
> CN.global
[1] 131.3154
> ## Not run:
> ##D # gwr.lcr function with a global bandwidth to check that the global CN is found
> ##D gwr.lcr1 <- gwr.lcr(GenEl2004~DiffAdd+LARent+SC1+Unempl+LowEduc+Age18_24
> ##D +Age25_44+Age45_64, data=Dub.voter, bw=10000000000)
> ##D summary(gwr.lcr1$SDF$Local_CN)
> ##D
> ##D # Find and map the local CNs from a basic GWR fit using the lcr-gwr function
> ##D #(note this is NOT the locally-compensated ridge GWR fit as would need to set
> ##D #lambda.adjust=TRUE and cn.thresh=30, say)
> ##D
> ##D bw.lcr2 <- bw.gwr.lcr(GenEl2004~DiffAdd+LARent+SC1+Unempl+LowEduc+Age18_24
> ##D +Age25_44+Age45_64, data=Dub.voter, kernel="bisquare", adaptive=TRUE)
> ##D gwr.lcr2 <- gwr.lcr(GenEl2004~DiffAdd+LARent+SC1+Unempl+LowEduc+Age18_24
> ##D +Age25_44+Age45_64, data=Dub.voter, bw=bw.lcr2, kernel="bisquare", adaptive=TRUE)
> ##D if(require("RColorBrewer"))
> ##D spplot(gwr.lcr2$SDF,"Local_CN",col.regions=brewer.pal(9,"YlOrRd"),cuts=8,
> ##D main="Local CN")
> ## End(Not run)
>
>
>
>
>
> dev.off()
null device
1
>