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".
numeric: Proportion of the population living below the poverty line
character: Lorenz curve methodology. Either "lb" or "lq".
numeric: Number of bins. Required for estimate = "lorenz".
character: API version
character: Response format either of c("rds", "json", "csv")
logical: If TRUE (the default) the response is returned as a
tibble
character: Server. For WB internal use only
data.frame
if (FALSE) { # \dontrun{
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.001013, 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, # default is 1.
povline = 2.15) # default is 1.
# 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")
} # }