最好用原始数据来算,用ineq是很简单的事,只要输入数据向量即可。
ineq {ineq} R Documentation
Inequality Measures
Description
computes the inequality within a vector according to the specified inequality measure
Usage
ineq(x, parameter = NULL, type = c("Gini", "RS", "Atkinson", "Theil", "Kolm", "var",
"square.var", "entropy"))
Gini(x)
RS(x)
Atkinson(x, parameter = 0.5)
Theil(x, parameter = 0)
Kolm(x, parameter = 1)
var.coeff(x, square = FALSE)
entropy(x, parameter = 0.5)
Arguments
x a vector containing at least non-negative elements
parameter parameter of the inequality measure (if set to NULL the default parameter of the respective measure is used)
type character string giving the measure used to compute inequality. must be one of the strings in the default argument (the first character is sufficient). defaults to "Gini".
square logical. Argument of the function var.coeff, for details see below.
Details
ineq is just a wrapper for the inequality measures Gini, RS, Atkinson, Theil, Kolm,var.coeff, entropy. If parameter is set to NULL the default from the respective function is used.
Gini is the Gini coefficient, RS is the the Ricci-Schutz coefficient (also called Pietra's measure), Atkinson gives Atkinson's measure and Kolm computes Kolm's measure.
If the parameter in Theil is 0 Theil's entropy measure is computed, for every other value Theil's second measure is computed.
ineq(x, type="var") and var.coeff(x) respectively compute the coefficient of variation, while ineq(x,type="square.var") and var.coeff(x, square=TRUE) compute the squared coefficient of variation.
entropy computes the generalized entropy, which is for parameter 1 equal to Theil's entropy coefficient and for parameter 0 equal to the second measure of Theil.
Value
the value of the inequality measure