lorenz | R Documentation |
lorenz
, lorenz.default
, lorenz.locfit
and
lorenz.incdist
compute a (possibly generalized) Lorenz curve. The
default method assumes the data are vectors, the locfit method assumes that
the function is applied to a locfit density object, and the incdist method
assumes the object has been created by the incdist methods. The curve is
estimated at a given number of points or at every point in the data.
lorenz(x, ...)
x |
a numerical vector whose Lorenz curve is to be estimated |
w |
an optional vector of non-negative integer values weights |
obj |
a locfit density object |
ranked |
an optional vector of length(x) which defines the ordering. If not x, lorenz returns the concentration curve of x for the variable given in ranked. |
q |
an integer or logical. If an integer, it is the number of equally spaced points at which the Lorenz curve ordinates are estimated. If FALSE, then the Lorenz curve is estimated at every point in x. |
p |
the population points at which the Lorenz curve is estimated. Defaults to equally spaced point on the unit interval. If given, then q is set to the length of this (minus one). |
data |
the data frame where the variables are found. |
subset |
use this subset of the data |
na.rm |
a logical value governing the treatment of NA:s. If true, NAs are removed. |
cov |
a logical indicating whether the variance covariance matrix of the lorenz curve is to be estimated |
no.negatives |
indicates whether or not negative incomes should be allowed |
cutoffs |
the values of the q-1 cutoffs for the quantile groups (may be used in within-group estimation) |
group.cutoffs |
a logical, indicating whether each group in the incdist object should use their own quantile cutoffs or if the overall cutoffs should be used. |
var.cov
is a utility function, invoked when cov = T
for
lorenz.default
, and estimates the variance-covariance matrix of the
lorenz ordinates and income shares.
print and summary methods are provided, as well as coercion to data fame (can be useful when combined e.g. with lattice to produce good graphics.
dominates.lorenz
compares two lorenz curves and returns (1=x L
dominates y, 0 = curves cross or are identical, -1 = y L dominates x).
dominates.lorenz_list
takes a list of lorenz curves and computes an
upper triangular matrix with elements dominates.lorenz(row, column)
The function computes an ordinary lorenz curve. The summary and plot methods allow also a generalized (L*mean) be plotted and summarized. The weights are for the time being assumed to be positive integers, although this will hopefully change soon.
Later on this function should know about income distribution objects. I am
also considering extending it to be able to handle locfit
,
density
and ecdf
objects, at least.
Simple summary, print and plot methods are provided.
There is a substantial literature on calculating standard errors for Lorenz
curve ordinates. If cov = TRUE
is chosen and q = FALSE
, the
returned object includes the variance matrix of the ordinates and of the
income shares, estimated as shown in Beach and Davidson (1983) and Beach and
Kaliski (1986). The R package boot
is probably quite useful
for doing so here, not least because all interesting work involving Lorenz
curves concerns the comparison of two (or more) Lorenz curves, making it
most often a two-sample problem.
A object of class lorenz with elements
p |
the population shares. |
ordinates |
the Lorenz curve ordinates. |
mean |
the
(weighted) mean of |
n |
the sample size. |
sum.weights |
the sum of weights. |
quintile.means |
(if |
quintile.shares |
(if |
Markus Jantti markus.jantti@iki.fi
lambert1993incdist \insertRefbeachanddavidson1983incdist \insertRefbeachandkaliski1986incdist
weighted_mean
, tip
,
locfit
lorenz(runif(10), q = FALSE)
n <- 100
income <- exp(10 + rnorm(n)*sqrt(2))
weight <- rpois(n,7)
lor <- lorenz(income, weight, p = c(0, .5, .7, .9, .98, 1))
lor <- lorenz(income, weight, q = 5)
plot(lor, main = "Lorenz curve")
plot(lor, lor.type = "gen", main = "Generalized Lorenz curve")
lor.1 <- lorenz(runif(100))
lor.2 <- lorenz(rexp(100))
lor.3 <- lorenz(rexp(100), cov = TRUE)
plot.lorenz_list(list("1"=lor.1, "2"=lor.2))
dominates.lorenz(lor.1, lor.2)
dominates.lorenz_list(list("1"=lor.1, "2"=lor.2))
library(locfit)
x <- runif(500)
y <- rexp(500)
lf.1 <- lorenz(locfit(~ x))
lf.2 <- lorenz(locfit(~ y))
dominates.lorenz(lor.1, lor.2)
dominates.lorenz_list(list("1"=lor.1, "2"=lor.2))
plot.lorenz_list(list("1"=lor.1, "2"=lor.2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.