wt.var: Aggregation functions provided by spacom

Description Usage Arguments Details Value Author(s) References Examples

Description

Spacom provides a set of aggregation functions which can be used with the functions SpawAggregate and ExploreMLSpawAggregate. See Details for descriptions of each function. Note that you are not restricted to these.

User supplied aggregation functions can be used if they have the form

x_w = f(x, w, ...)

where x is the data to be aggregated, w the weights to be applied. Any number of additional arguments may also be used (see argument additional.args in SpawAggregate for details on additional arguments. The return value x_w must be a scalar value (i.e. not a vector).

Usage

1
2
3
4
5
6
7
8

Arguments

data

A vector of data to be aggregated

weights

A vector of weights. These weights are computed by combining the spatial weights and design weights for each context.

groups

name of the column used to group data (only wt.group.gini)

Details

  1. wt.var(data, weights) Computes the weighted variance according to

    Var(x) = sum(w*(data-mu))/sum(w)

    where the weighted mean is mu

    mu = weighted.mean(data, weights)

  2. wt.sd(data, weights) Computes the weighted standard deviation according to

    sd = sqrt(wt.var(data, weights))

  3. wt.gini The weighted Gini coefficient is given by

    where mu is

    mu = sum(w*x)

  4. wt.gini.categ Spacom also allows for the computation of inequality indicators for categorical variables. In this case, one has no x_i value but only the weighted frequencies f_i for each category. For that case, the Gini becomes

    G = 1-sum(f^2)

    The weighted frequencies are computed from data and weights

  5. wt.gini.group get from guy

Value

A scalar value of type numeric. For user-supplied aggregation functions, this can potentially be of a differenet type.

Author(s)

Mathieu Cossuta, Till Junge, Sandra Penic, Guy Elcheroth

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## Creating indicators of spatially weighted inequalities 

## load individual level data and remove missings
data(traces_ind)
traces_ind <- na.exclude(traces_ind)

## create variable "simulated income" in the dataset
## the variable is created only in demonstrative purposes, 
## and it is not part of the TRACES dataset

traces_ind$sim_inc <- rnorm(nrow(traces_ind), 1000, 100)

## Step 1: Load distance matrix and create weights
data(d_geo)
geow.50 <- WeightMatrix(d_geo, bandwidth=50)

## Step 2: Spatially weighted gini for simulated income
si.gini <- SpawAggregate(contextual.data=traces_ind,
                         context.id="area.name",
                         contextual.names="sim_inc",
                         contextual.weight.matrices=geow.50,
                         aggregation.functions="wt.gini",
                         design.weight.names=NULL,
                         nb.resamples=5)

## Step 2: Spatially weighted gini for groups (Spatially weighted inequalities
## in simulated income for men and women)  

si.gini.gr <- SpawAggregate(contextual.data=traces_ind,
                            context.id="area.name",
                            contextual.names="sim_inc",
                            contextual.weight.matrices=geow.50,
                            aggregation.functions="wt.gini.group",
                            additional.args="male",
                            design.weight.names=NULL,
                            nb.resamples=5)   

spacom documentation built on May 1, 2019, 7:35 p.m.