| Title: | Transformed and Relative Lorenz Curves for Survey Weighted Data |
|---|---|
| Description: | Functions for constructing Transformed and Relative Lorenz curves with survey sampling weights. Given a variable of interest measured in two groups with scaled survey weights so that their hypothetical populations are of equal size, tlorenz() computes the proportion of members of the group with smaller values (ordered from smallest to largest) needed for their sum to match the sum of the top qth percentile of the group with higher values. rlorenz() shows the fraction of the total value of the group with larger values held by the pth percentile of those in the group with smaller values. Fd() is a survey weighted cumulative distribution function and Eps() is a survey weighted inverse cdf used in rlorenz(). Ramos, Graubard, and Gastwirth (2025) <doi:10.1093/jrsssa/qnaf044>. |
| Authors: | Mark Ramos [aut, cre, cph] |
| Maintainer: | Mark Ramos <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.1 |
| Built: | 2026-05-14 09:53:41 UTC |
| Source: | https://github.com/cran/glorenz |
Inverse cumulative distribution function for a subset of the dataset
Eps(p, data, group = "qtyvar")Eps(p, data, group = "qtyvar")
p |
cumulative distribution percentile |
data |
dataset with defined group and newwts columns |
group |
variable of interest |
Cumulative distribution percentile for quantile y
df_samp <- data.frame(qtyvar = rnorm(1000, mean = 5, sd = 2),newwts = rep(1, 1000)) Eps(0.25,df_samp) # Finds the quantile for 25th percentile in simulated data.df_samp <- data.frame(qtyvar = rnorm(1000, mean = 5, sd = 2),newwts = rep(1, 1000)) Eps(0.25,df_samp) # Finds the quantile for 25th percentile in simulated data.
Cumulative distribution function for a subset of the dataset
Fd(y, data, group = "qtyvar", newwts = "newwts")Fd(y, data, group = "qtyvar", newwts = "newwts")
y |
cumulative distribution quantile |
data |
dataset with defined group and newwts columns |
group |
variable of interest |
newwts |
sampling weights |
Cumulative distribution percentile for quantile y
df_samp <- data.frame(qtyvar = rnorm(1000, mean = 5, sd = 2),newwts = rep(1, 1000)) Fd(3.5,df_samp) # Finds the percentile for 3.5 in simulated data.df_samp <- data.frame(qtyvar = rnorm(1000, mean = 5, sd = 2),newwts = rep(1, 1000)) Fd(3.5,df_samp) # Finds the percentile for 3.5 in simulated data.
Compute relevant probabilities and estimates for selecting performance criteria
rlorenz(p, data, group, edata, newwts = "newwts")rlorenz(p, data, group, edata, newwts = "newwts")
p |
percentile based on data from group with lower mean value |
data |
dataset of group with higher mean value. |
group |
variable of interest. Entered in quotes.Must be present in data and edata. |
edata |
dataset of group with lower mean value.Must have defined newwts column. Sum of newwts for edata must be equal to sum of newwts for data. |
newwts |
sampling weights. "newwts" by default. Must be present in data and edata. |
Relative Lorenz function value for p
df_samp <- data.frame(x1 = rnorm(500, mean = 5, sd = 2),newwts = rep(1, 500)) df_samp2 <- data.frame(x1 = rnorm(500, mean = 4.5, sd = 2),newwts = rep(1, 500)) p_vals <- seq(0, 1, length.out = 100) lc_vals <- rlorenz(p_vals, data = df_samp, group = "x1", edata = df_samp2) #Creates relative Lorenz curve values for two sets of simulated datadf_samp <- data.frame(x1 = rnorm(500, mean = 5, sd = 2),newwts = rep(1, 500)) df_samp2 <- data.frame(x1 = rnorm(500, mean = 4.5, sd = 2),newwts = rep(1, 500)) p_vals <- seq(0, 1, length.out = 100) lc_vals <- rlorenz(p_vals, data = df_samp, group = "x1", edata = df_samp2) #Creates relative Lorenz curve values for two sets of simulated data
Compute relevant probabilities and estimates for selecting performance criteria
tlorenz(q, d1, group, d2, newwts = "newwts")tlorenz(q, d1, group, d2, newwts = "newwts")
q |
1-percentile of data on variable of interest in group with higher mean value |
d1 |
dataset of group with higher mean value. |
group |
variable of interest. Entered in quotes.Must be present in d1 and d2 |
d2 |
dataset of group with lower mean value. |
newwts |
sampling weights. "newwts" by default. Must be present in data and edata. |
Transformed Lorenz function value for q
df_samp <- data.frame(x1 = rnorm(500, mean = 5, sd = 2),newwts = rep(1, 500)) df_samp2 <- data.frame(x1 = rnorm(500, mean = 4.5, sd = 2),newwts = rep(1, 500)) p_vals <- seq(0, 1, length.out = 100) lc_vals <- tlorenz(p_vals, d1 = df_samp, group = "x1", d2 = df_samp2) #Creates transformed Lorenz curve values for two sets of simulated datadf_samp <- data.frame(x1 = rnorm(500, mean = 5, sd = 2),newwts = rep(1, 500)) df_samp2 <- data.frame(x1 = rnorm(500, mean = 4.5, sd = 2),newwts = rep(1, 500)) p_vals <- seq(0, 1, length.out = 100) lc_vals <- tlorenz(p_vals, d1 = df_samp, group = "x1", d2 = df_samp2) #Creates transformed Lorenz curve values for two sets of simulated data