Description Usage Arguments Examples
A function that calculates the Generalised Gini coefficient from an observed Gini and a null Gini corresponding to an alternative distribution. For example, when events are sparsely distributed in the population, ie there are more targets than events, the null Gini can correspond to the maximal equality diagonal. Alternatively, the null Gini can represent the distribution expected under chance as predicted by a Monte Carlo simulation.
1 | gengini(G, Gnull)
|
G |
a number depicting a Gini coefficient. Accepts values between 0 and 1 inclusive. |
Gnull |
a number depicting a null Gini coefficient. Accepts values between 0 and 1 inclusive. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Generalising by adjusting to expected under chance
g1 <- ineq::Gini(testdata$extortions)
# simulating 99 distributions under chance
reps <- lapply(1:99, function(x){rpois(length(testdata$extortions),
mean(testdata$extortions))})
# Calculating their gini coefficients
sim <- unlist(lapply(reps, function(x) ineq::Gini(x)))
# Selecting the mean Gini coefficient
gnull <- mean(sim)
gengini(g1, gnull)
# Generalising by adjusting to maximal equality
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.