Description Usage Arguments Details Value See Also Examples
Calculates kernel density functions for geo-coded data based on straight-line distances between observations
1 | geodensity(longvar,latvar,window=.25,kern="tcub",alldata=FALSE)
|
longvar |
Longitude variable, in degrees. |
latvar |
Latitude variable, in degrees. |
window |
Window size. Default: 0.25. |
kern |
Kernel weighting functions. Default is the tri-cube. Options include "rect", "tria", "epan", "bisq", "tcub", and "trwt". |
alldata |
If alldata=T, each observation is used as a target value for x. When alldata=F, the function is estimated at a set of points chosen by the locfit program using an adaptive decision tree approach, and the smooth12 command is used to interpolate to the full set of observations. Specifying alldata=T can lead to long estimation times. |
The geodistance function is used to calculate straight-line distances between all observations and each target point. The vector of distances for a given target value is d. The window is determined by finding dmax = quantile(d, window). The estimated density at the target point is simply:
f = (1/(dmax*n)) ∑_i K ( d_i/dmax )
Available kernel weighting functions include the following:
Kernel | Call abbreviation | Kernel function K(z) |
Rectangular | ``rect'' | 1/2 * I(|z|<1) |
Triangular | ``tria'' | (1-|z|) * I(|z|<1) |
Epanechnikov | ``epan'' | 3/4 * (1-z^2)*I(|z| < 1) |
Bi-Square | ``bisq'' | 15/16 * (1-z^2)^2 * I(|z| < 1) |
Tri-Cube | ``tcub'' | 70/81 * (1-|z|^3)^3 * I(|z| < 1) |
Tri-Weight | ``trwt'' | 35/32 * (1-z^2)^3 * I(|z| < 1) |
The gaussian kernel is not available.
If alldata=T, each data point in turn is used as a target point. If alldata=F, locfit is used to find a set of target points, and the smooth12 command is used to interpolate to the full set of observations. The matrix of target coordinates is stored in target, and the estimated densities at the target points are stored in dens.target. If alldata=T, target contains the full set of values for longitude and latitude, and dens.target = denshat.
target |
The matrix of target values. Dimensions = ntx2, where nt is the number of target points. First column = longitude, second column = latitude. |
dens.target |
The estimated densities at the target coordinates. |
denshat |
The estimated densities at the original data points. |
geodistance
geogravity
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run:
library(spdep)
library(RColorBrewer)
cook <- readShapePoly(system.file("maps/CookCensusTracts.shp",package="McSpatial"))
# measure distance to Chicago city center
lmat <- coordinates(cook)
cook$longitude <- lmat[,1]
cook$latitude <- lmat[,2]
fit <- geodensity(cook$longitude, cook$latitude)
cook$denshat <- fit$denshat
brks <- seq(min(cook$denshat,na.rm=TRUE),max(cook$denshat,na.rm=TRUE),length=9)
spplot(cook,"denshat",at=brks,col.regions=rev(brewer.pal(9,"RdBu")),
main="Census Tract Densities")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.