Get grouped stats from the PIP API.
numeric: Cumulative welfare values, expressed in shares. Any length. They should be monotonically increasing, and sum to 1.
numeric: Cumulative population values, expressed in shares. Any length. They should be monotonically increasing, and sum to 1.
character: One of "stats", "lorenz", "params".
numeric: Requested mean.
numeric: Poverty line. Required for estimate = "stats".
One numeric population share from 0 to 1, or NULL.
character: Lorenz curve methodology. Either "lb" or "lq".
numeric: Number of bins. Required for estimate = "lorenz".
API version. Currently only "v1" is supported.
Response format: "rds", "json", or "csv".
One non-missing logical value. If TRUE (the default),
return simplified data.
One non-empty server name, or NULL for the production server.
For World Bank internal use only.
A data frame when simplify = TRUE, or a pip_api list when
simplify = FALSE.
if (interactive()) {
datt_data <- data.frame(p = c(0.0092, 0.0339, 0.0850, 0.160, 0.2609, 0.4133,
0.5497, 0.7196, 0.8196, 0.9174, 0.9570, 0.9751,
1),
L = c(0.00208, 0.01013, 0.03122, 0.07083, 0.12808,
0.23498, 0.34887, 0.51994, 0.64270, 0.79201,
0.86966, 0.91277, 1))
# estimate = 'stats': retrieve poverty statistics.
stats <- get_gd(cum_welfare = datt_data$L, cum_population = datt_data$p,
estimate = "stats",
requested_mean = 19,
povline = 2.15)
# estimate = 'lorenz': retrieve Lorenz curve data points for a specified number of bins.
## Best lorenz curve methodolody selected by default:
lorenz <- get_gd(cum_welfare = datt_data$L,
cum_population = datt_data$p,
estimate = "lorenz",
n_bins = 100) # must be specified, default is NULL.
## Specify lorenz curve methodology:
### Beta Lorenz ("lb")
lorenz_lb <- get_gd(cum_welfare = datt_data$L,
cum_population = datt_data$p,
estimate = "lorenz",
lorenz = "lb",
n_bins = 100)
### Quadratic Lorenz ("lq")
lorenz_lq <- get_gd(cum_welfare = datt_data$L,
cum_population = datt_data$p,
estimate = "lorenz",
lorenz = "lq",
n_bins = 100)
# estimate = 'params': retrieve regression parameters used for the lorenz curve estimation.
params <- get_gd(cum_welfare = datt_data$L,
cum_population = datt_data$p,
estimate = "params")
}