Description Usage Arguments Details Value See Also Examples
Calculates a variable showing the average value for each observation of a gravity measure of the spatial interaction between the observation and the other points in a data set.
1 2 | geogravity(x,longvar,latvar,alpha=1,maxd=NULL,alldata=FALSE,
window=.10,outmatrix=FALSE)
|
x |
The variable of interest, e.g., population or employment. |
longvar |
Longitude variable, in degrees. |
latvar |
Latitude variable, in degrees. |
alpha |
The α parameter for the distance variables. Default: alpha = 1. |
maxd |
Maximum distance, beyond which observations get zero weight. Default: all observations are included in the calculations. |
alldata |
If FALSE, interpolates between target points rather than making the calculations at every observation. Default: alldata=FALSE. |
window |
Window size used to determine a set of target points when alldata=FALSE. Default: window = .10. |
outmatrix |
If TRUE and alldata==TRUE, stores the full matrix of gravity values. Default: outmatrix=FALSE. |
The gravity measure of the spatial interaction between two points i and j is g_{ij} = P_i P_j / d_{ij}^α if d_{ij} < maxd and g_{ij} = 0 if d_{ij} > maxd, where P is a variable such as population or employment that measures the importance of the observation, d_{ij} is the straight-line distance between observations i and j, and α is a parameter. The variable P is provided by the argument x. The full n x n matrix of values is stored in dmat if alldata=TRUE and outmatrix=TRUE, with the diagonal elements set to zero.
The "gravity variable" that is stored in gravity is the average value for each observation:
g_i = (1/(n-1)) ∑ g_{ij}
By default, the locfit program is used to find a set of target values for calculating g_{ij}. The full set of observations is used for the j index, but a smaller set of observations is used for the target values, i. The abbreviated set of g_i values is then interpolated to the full set of data points using the smooth12 command. The vector of target observation numbers is stored in targetobs.
targetobs |
The vector of target observation numbers. |
gtarget |
The gravity variable at the target points. |
gravity |
The gravity variable for the full data set. |
dmat |
The full nxn matrix of results, if outmatrix=TRUE and alldata=TRUE. The diagonal elements are set to zero. |
geodistance
geodensity
1 2 3 4 5 6 7 8 9 | library(spdep)
cook <- readShapePoly(system.file("maps/CookCensusTracts.shp",package="McSpatial"))
cook <- cook[cook$POPULATION>0&cook$AREA>0,]
cook$lndens <- log(cook$POPULATION/cook$AREA)
lmat <- coordinates(cook)
longitude <- lmat[,1]
latitude <- lmat[,2]
fit <- geogravity(cook$lndens,longitude,latitude)
cook$gravity <- fit$gravity
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.