convey (version 0.2.2)

svyzengacurve: Zenga inequality curve (EXPERIMENTAL)

Description

Estimate the Zenga curve, an inequality graph

Usage

svyzengacurve(formula, design, ...)

# S3 method for survey.design svyzengacurve( formula, design, quantiles = seq(0, 1, 0.1), empirical = FALSE, plot = TRUE, add = FALSE, curve.col = "red", ci = TRUE, alpha = 0.05, na.rm = FALSE, ... )

# S3 method for svyrep.design svyzengacurve( formula, design, quantiles = seq(0, 1, 0.1), empirical = FALSE, plot = TRUE, add = FALSE, curve.col = "red", ci = TRUE, alpha = 0.05, na.rm = FALSE, ... )

# S3 method for DBIsvydesign svyzengacurve(formula, design, ...)

Arguments

formula

a formula specifying the income variable

design

a design object of class survey.design or class svyrep.design from the survey library.

...

additional arguments passed to plot methods

quantiles

a sequence of probabilities that defines the quantiles sum to be calculated

empirical

Should an empirical Zenga curve be estimated as well? Defaults to FALSE.

plot

Should the Zenga curve be plotted? Defaults to TRUE.

add

Should a new curve be plotted on the current graph?

curve.col

a string defining the color of the curve.

ci

Should the confidence interval be plotted? Defaults to TRUE.

alpha

a number that especifies de confidence level for the graph.

na.rm

Should cases with missing values be dropped? Defaults to FALSE.

Value

Object of class "svyquantile", which are vectors with a "quantiles" attribute giving the complement of the ratio between the lower and upper means, and a "SE" attribute giving the standard errors of the estimates.

Details

WARNING: this is an experimental version. Use with caution.

You must run the convey_prep function on your survey design object immediately after creating it with the svydesign or svrepdesign function.

Notice that the 'empirical' curve is observation-based and is based on the Lorenz curve formula actually used to calculate the Gini index. On the other hand, the quantile-based curve is used to estimate the complement of the ratio between the means, SEs and confidence intervals.

This way, as the number of quantiles of the quantile-based function increases, the quantile-based curve approaches the observation-based curve.

References

Marcella Polisicchio and Francesco Porro (2011). A Comparison Between Lorenz L(P) Curve and Zenga I(P) Curve. Statistica Applicata, v. 21, n. 3-4, 289-301.

Matti Langel (2012). Measuring inequality in finite population sampling. PhD thesis. URL http://doc.rero.ch/record/29204.

Jean-Claude Deville (1999). Variance estimation for complex statistics and estimators: linearization and residual techniques. Survey Methodology, 25, 193-203, URL http://www5.statcan.gc.ca/bsolc/olc-cel/olc-cel?lang=eng&catno=12-001-X19990024882.

See Also

svyquantile

Examples

Run this code
# NOT RUN {
library(survey)
library(laeken)
data(eusilc) ; names( eusilc ) <- tolower( names( eusilc ) )

# linearized design
des_eusilc <- svydesign( ids = ~rb030 , strata = ~db040 ,  weights = ~rb050 , data = eusilc )
des_eusilc <- convey_prep( des_eusilc )
svyzengacurve( ~eqincome , des_eusilc,  alpha = .01 )

# replicate-weighted design
des_eusilc_rep <- as.svrepdesign( des_eusilc , type = "bootstrap" )
des_eusilc_rep <- convey_prep( des_eusilc_rep )

svyzengacurve( ~eqincome , des_eusilc_rep,  alpha = .01 )

# }
# NOT RUN {
# linearized design using a variable with missings
svyzengacurve( ~py010n , des_eusilc, alpha = .01 )
svyzengacurve( ~py010n , des_eusilc, alpha = .01, na.rm = TRUE )
# demonstration of `curve.col=` and `add=` parameters
svyzengacurve( ~eqincome , des_eusilc,  alpha = .05 , add = TRUE , curve.col = 'green' )
# replicate-weighted design using a variable with missings
svyzengacurve( ~py010n , des_eusilc_rep, alpha = .01 )
svyzengacurve( ~py010n , des_eusilc_rep, alpha = .01, na.rm = TRUE )



# database-backed design
library(RSQLite)
library(DBI)
dbfile <- tempfile()
conn <- dbConnect( RSQLite::SQLite() , dbfile )
dbWriteTable( conn , 'eusilc' , eusilc )

dbd_eusilc <-
	svydesign(
		ids = ~rb030 ,
		strata = ~db040 ,
		weights = ~rb050 ,
		data="eusilc",
		dbname=dbfile,
		dbtype="SQLite"
	)

dbd_eusilc <- convey_prep( dbd_eusilc )

svyzengacurve( ~eqincome , dbd_eusilc, alpha = .01 )

# highlighting the difference between the quantile-based curve and the empirical version:
svyzengacurve( ~eqincome , dbd_eusilc, seq(0,1,.1), empirical = TRUE, curve.col = "green" )
svyzengacurve( ~eqincome , dbd_eusilc, seq(0,1,.1), alpha = .01, add = TRUE )
legend( "bottomleft", c("Quantile-based", "Empirical"), lwd = c(1,1), col = c("red", "green"))

# as the number of quantiles increases, the difference between the curves gets smaller
svyzengacurve( ~eqincome , dbd_eusilc, seq(0,1,.01), empirical = TRUE, curve.col = "green" )
svyzengacurve( ~eqincome , dbd_eusilc, seq(0,1,.01), alpha = .01, add = TRUE )
legend( "bottomleft", c("Quantile-based", "Empirical"), lwd = c(1,1), col = c("red", "green"))

dbRemoveTable( conn , 'eusilc' )

dbDisconnect( conn , shutdown = TRUE )

# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace