gwda: GW Discriminant Analysis

View source: R/gwda.r

gwdaR Documentation

GW Discriminant Analysis

Description

This function implements GW discriminant analysis, where location-wise probabilities and their associated entropy are also calculated.

Usage

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 class 'gwda'
print(x, ...)

Arguments

formula

Model formula of a formula object

data

a Spatial*DataFrame, i.e. SpatialPointsDataFrame or SpatialPolygonsDataFrame as defined in package sp, or a sf object defined in package sf

predict.data

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.

validation

If TRUE, the results from the prediction will be validated and the correct proportion will be calculated.

COV.gw

if true, localised variance-covariance matrix is used for GW discriminant analysis; otherwise, global variance-covariance matrix is used

mean.gw

if true, localised mean is used for GW discriminant analysis; otherwise, global mean is used

prior.gw

if true, localised prior probability is used for GW discriminant analysis; otherwise, fixed prior probability is used

prior

a vector of given prior probability

wqda

if TRUE, weighted quadratic discriminant analysis will be applied; otherwise weighted linear discriminant analysis will be applied

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

adaptive

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)

bw

bandwidth used in the weighting function, possibly calculated by bw.gwpca;fixed (distance) or adaptive bandwidth(number of nearest neighbours)

p

the power of the Minkowski distance, default is 2, i.e. the Euclidean distance

theta

an angle in radians to rotate the coordinate system, default is 0

longlat

if TRUE, great circle distances will be calculated

dMat

a pre-specified distance matrix, it can be calculated by the function gw.dist

x

an object of class “gwda”

...

arguments passed through (unused)

Value

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.

Author(s)

Binbin Lu binbinlu@whu.edu.cn

References

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

Examples

## Not run: 
 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")
 
## End(Not run)

GWmodel documentation built on Sept. 11, 2024, 9:09 p.m.