Learn R Programming

spacom (version 1.0-5)

SpawExact: Create and describe spatially weighted precise contextual indicators

Description

This step-2 function should be used to create spatially weighted context data when contextual indicators are directly available as precise macro-level measures (e.g., population values based on census or registry data, or precise geographic measures). The generated context data can be adjusted by user-defined population weights.

Usage

SpawExact(precise.data, context.id, contextual.names, contextual.weight.matrices, population.weight.names = NULL)

Arguments

precise.data
A data.frame consisting of precise contextual indicators and a context ID variable
context.id
The name of the context ID variable. This variable allows matching contextual units from different data sets (precise.data, contextual.weight.matrix). Values can by of any type but need to be defined consitently across data sets.

contextual.names
A list of column names of contextual variables to be weighted
contextual.weight.matrices
A list of square weight matrices of dimension $n by n$, where $n$ is the number of contextual units to be applied to the variable specified in contextual.names, respectively.
population.weight.names
A list of column names to be used as population weights. By default NULL which means that no population weighting is performed. If only one name is provided, the corresponding column is used as a weight for all contextual names

Value

A data.frame containing the spatially weighted contextual.names.

References

Elcheroth, G., Penic, S., Fasel, R., Giudici, F., Glaeser, S., Joye, D., Le Goff, J.-M., Morselli, D., & Spini, D. (2012). Spatially weighted context data: a new approach for modelling the impact of collective experiences. LIVES Working Papers, 19.

Examples

Run this code
## Creating spatially weighted precise contextual indicator - spatially weighted 
## ethnic homogeneity across TRACES areas.
## This is step-2 function

## Step 1: Load distance matrix and create weights

data(d_geo)
geow.50 <- WeightMatrix(d_geo, bandwidth=50)

## Step 2: Load dataframe with precise contextual indicator and 
## create spatially weighted indicator

data(homog_census)

homog.g50 <- SpawExact(precise.data=homog_census,
                       context.id="area.name",
                       contextual.names="Homog_00",
                       contextual.weight.matrices=geow.50)

Run the code above in your browser using DataLab