Description Usage Arguments Details Value Author(s) References Examples
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).
1 2 3 4 5 6 7 8 | wt.sd(data, weights=rep(1, length(data)))
wt.var(data, weights=rep(1, length(data)))
wt.gini(data, weights=rep(1, length(data)))
wt.gini.categ(data, weights=rep(1, length(data)))
wt.Theil(data, weights=rep(1, length(data)))
wt.RS(data, weights=rep(1, length(data)))
wt.Atkinson(data, weights=rep(1, length(data)))
wt.gini.group(data, weights=rep(1, length(data)), groups)
|
data |
A |
weights |
A |
groups |
name of the column used to group data (only |
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)
wt.sd(data, weights)
Computes the weighted standard deviation according to
sd = sqrt(wt.var(data, weights))
wt.gini
The weighted Gini coefficient is given by
where mu is
mu = sum(w*x)
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
wt.gini.group
get from guy
A scalar value of type numeric
. For user-supplied aggregation
functions, this can potentially be of a differenet type.
Mathieu Cossuta, Till Junge, Sandra Penic, Guy Elcheroth
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.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.