This function implements GW discriminant analysis, where location-wise probabilities and their associated entropy are also calculated.
gwda(formula, data, predict.data,validation = T, COV.gw=T,
mean.gw=T, prior.gw=T, prior=NULL, wqda =F,
kernel = "bisquare", adaptive = FALSE, bw,
p = 2, theta = 0, longlat = F,dMat)
# S3 method for gwda
print(x, ...)
An object of class “gwda”. This includes a SpatialPointsDataFrame (may be gridded) or SpatialPolygonsDataFrame object, SDF, (see package “sp”) or sf object (see package “sf”) with, following the use of new version of gwda, the probabilities for each level, the highest probabiliity and the entropy of the probabilities in its “data” slot.
Model formula of a formula object
a Spatial*DataFrame, i.e. SpatialPointsDataFrame or SpatialPolygonsDataFrame as defined in package sp, or a sf object defined in package sf
a Spatial*DataFrame object for prediction, i.e. SpatialPointsDataFrame or SpatialPolygonsDataFrame as defined in package sp; if it is not given, the traing data will be predicted using leave-one-out cross-validation.
If TRUE, the results from the prediction will be validated and the correct proportion will be calculated.
if true, localised variance-covariance matrix is used for GW discriminant analysis; otherwise, global variance-covariance matrix is used
if true, localised mean is used for GW discriminant analysis; otherwise, global mean is used
if true, localised prior probability is used for GW discriminant analysis; otherwise, fixed prior probability is used
a vector of given prior probability
if TRUE, weighted quadratic discriminant analysis will be applied; otherwise weighted linear discriminant analysis will be applied
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
if TRUE calculate an adaptive kernel where the bandwidth 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)
bandwidth used in the weighting function, possibly calculated by bw.gwpca;fixed (distance) or adaptive bandwidth(number of nearest neighbours)
the power of the Minkowski distance, default is 2, i.e. the Euclidean distance
an angle in radians to rotate the coordinate system, default is 0
if TRUE, great circle distances will be calculated
a pre-specified distance matrix, it can be calculated by the function gw.dist
an object of class “gwda”
arguments passed through (unused)
Binbin Lu binbinlu@whu.edu.cn
Brunsdon, C, Fotheringham S, and Charlton, M (2007), Geographically Weighted Discriminant Analysis, Geographical Analysis 39:376-396
Lu B, Harris P, Charlton M, Brunsdon C (2014) The GWmodel R Package: further topics for exploring Spatial Heterogeneity using Geographically Weighted Models. Geo-spatial Information Science 17(2): 85-101
if (FALSE) {
data(USelect)
dMat <- gw.dist(coordinates(USelect2004))
bw <- bw.gwda(winner~unemploy+pctcoled+PEROVER65+pcturban+WHITE,data=USelect2004,
adaptive=TRUE,dMat=dMat)
ge.gwda <- gwda(winner~unemploy+pctcoled+PEROVER65+pcturban+WHITE,data=USelect2004,
bw=bw,adaptive=TRUE,dMat=dMat)
table(USelect2004$winner,ge.gwda$SDF$group.predicted)
spplot(ge.gwda$SDF, "entropy")
}
Run the code above in your browser using DataLab