geogravity: Gravity matrix and gravity variable calculations

Description Usage Arguments Details Value See Also Examples

View source: R/geogravity.R

Description

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.

Usage

1
2
geogravity(x,longvar,latvar,alpha=1,maxd=NULL,alldata=FALSE,
  window=.10,outmatrix=FALSE)

Arguments

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.

Details

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.

Value

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.

See Also

geodistance

geodensity

Examples

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

McSpatial documentation built on May 2, 2019, 9:32 a.m.