Welfare share by quantile in group data
pipgd_welfare_share_at.Rd
pipgd_welfare_share_at
returns the share of welfare held by the specified
share of the population in the parameter popshare
. Alternatively, you can
select the number of quantiles (10 be default), to estimate the corresponding
share of welfare in each.
Arguments
- params
list of parameters from
pipgd_validate_lorenz()
- welfare
numeric vector of cumulative share of welfare (income/consumption)
- weight
numeric vector of cumulative share of the population
- complete
logical: If TRUE, returns a list a cumulative returns from previously used
get_gd
functions. Default isFALSE
- lorenz
character or NULL. Lorenz curve selected. It could be "lq" for Lorenz Quadratic or "lb" for Lorenz Beta
- n
numeric scalar for the number of quantiles to be used in
popshare
- popshare
numeric: vector of share of population. Default is
seq(from = 1/n, to = 1, by = 1/n)
Value
Returns a nested list containing distribution statistics:
$dist_stats$pop_share
is a numeric vector containing the share of the
population.
$dist_stats$welfare_share_at
is a numeric vector showing the
corresponding share of welfare.
If complete = TRUE
, it returns a pipgd_params
object with additional
details and intermediate calculations.
Examples
# Example 1: Basic usage with default parameters
pipgd_welfare_share_at(welfare = pip_gd$L,
weight = pip_gd$P,
complete = FALSE)
#> $dist_stats
#> $dist_stats$popshare
#> [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
#>
#> $dist_stats$welfare_share_at
#> [1] 0.03911772 0.09067747 0.15263425 0.22412849 0.30507843 0.39614586
#> [7] 0.49903558 0.61752824 0.76157408 1.00000000
#>
#>
# Example 2: Specifying a custom number of quantiles (n = 5)
pipgd_welfare_share_at(welfare = pip_gd$L,
weight = pip_gd$P,
complete = FALSE,
n = 5)
#> $dist_stats
#> $dist_stats$popshare
#> [1] 0.2 0.4 0.6 0.8 1.0
#>
#> $dist_stats$welfare_share_at
#> [1] 0.09067747 0.22412849 0.39614586 0.61752824 1.00000000
#>
#>
# Example 3: Using a custom population share vector
custom_popshare_vector <- seq(from = 1/13, to = 1, length.out = 13)
pipgd_welfare_share_at(welfare = pip_gd$L,
weight = pip_gd$P,
complete = FALSE,
popshare = custom_popshare_vector)
#> $dist_stats
#> $dist_stats$popshare
#> [1] 0.07692308 0.15384615 0.23076923 0.30769231 0.38461538 0.46153846
#> [7] 0.53846154 0.61538462 0.69230769 0.76923077 0.84615385 0.92307692
#> [13] 1.00000000
#>
#> $dist_stats$welfare_share_at
#> [1] 0.02887655 0.06550084 0.10869119 0.15780056 0.21251996 0.27280064
#> [7] 0.33884270 0.41114336 0.49063514 0.57902253 0.67970615 0.80128755
#> [13] 1.00000000
#>
#>
# Example 4: Using a specified Lorenz curve (e.g., Lorenz Beta)
pipgd_welfare_share_at(welfare = pip_gd$L,
weight = pip_gd$P,
complete = FALSE,
lorenz = "lb")
#> $dist_stats
#> $dist_stats$popshare
#> [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
#>
#> $dist_stats$welfare_share_at
#> [1] 0.03809217 0.08976495 0.15119586 0.22213280 0.30303589 0.39493547
#> [7] 0.49966955 0.62069307 0.76615187 1.00000000
#>
#>
# Example 5: Detailed output with complete = TRUE
pipgd_welfare_share_at(welfare = pip_gd$L,
weight = pip_gd$P,
complete = TRUE)
#> $gd_params
#> $gd_params$lq
#> $gd_params$lq$reg_results
#> $gd_params$lq$reg_results$ymean
#> [1] 0.1219752
#>
#> $gd_params$lq$reg_results$sst
#> [1] 0.08456216
#>
#> $gd_params$lq$reg_results$coef
#> A B C
#> 0.8877478 -1.4514459 0.2026400
#>
#> $gd_params$lq$reg_results$sse
#> [1] 3.418058e-06
#>
#> $gd_params$lq$reg_results$r2
#> [1] 0.9999596
#>
#> $gd_params$lq$reg_results$mse
#> [1] 3.797842e-07
#>
#> $gd_params$lq$reg_results$se
#> [1] 0.006673127 0.019034521 0.012827923
#>
#>
#> $gd_params$lq$key_values
#> $gd_params$lq$key_values$e
#> [1] -0.638942
#>
#> $gd_params$lq$key_values$m
#> [1] -1.444296
#>
#> $gd_params$lq$key_values$n
#> [1] 1.044219
#>
#> $gd_params$lq$key_values$r
#> [1] 1.857124
#>
#> $gd_params$lq$key_values$s1
#> [1] -0.2814192
#>
#> $gd_params$lq$key_values$s2
#> [1] 1.004414
#>
#>
#> $gd_params$lq$validity
#> $gd_params$lq$validity$is_normal
#> [1] TRUE
#>
#> $gd_params$lq$validity$is_valid
#> [1] TRUE
#>
#> $gd_params$lq$validity$headcount
#> [1] 0.6284604
#>
#>
#>
#> $gd_params$lb
#> $gd_params$lb$reg_results
#> $gd_params$lb$reg_results$ymean
#> [1] -2.496791
#>
#> $gd_params$lb$reg_results$sst
#> [1] 10.98072
#>
#> $gd_params$lb$reg_results$coef
#> A B C
#> 0.5613532 0.9309501 0.5800259
#>
#> $gd_params$lb$reg_results$sse
#> [1] 0.003204989
#>
#> $gd_params$lb$reg_results$r2
#> [1] 0.9997081
#>
#> $gd_params$lb$reg_results$mse
#> [1] 0.0003561098
#>
#> $gd_params$lb$reg_results$se
#> [1] 0.014871578 0.005505620 0.006407669
#>
#>
#> $gd_params$lb$key_values
#> [1] NA
#>
#> $gd_params$lb$validity
#> $gd_params$lb$validity$is_valid
#> [1] TRUE
#>
#> $gd_params$lb$validity$is_normal
#> [1] TRUE
#> attr(,"label")
#> [1] "Normality with a mean of 1 and a poverty line of 1;1 times the mean."
#>
#> $gd_params$lb$validity$headcount
#> [1] 0.6161877
#>
#>
#>
#>
#> $data
#> $data$welfare
#> [1] 0.00208 0.01013 0.03122 0.07083 0.12808 0.23498 0.34887 0.51994 0.64270
#> [10] 0.79201 0.86966 0.91277 1.00000
#> attr(,"label")
#> [1] "Cumulative share of welfare"
#>
#> $data$weight
#> [1] 0.0092 0.0339 0.0850 0.1640 0.2609 0.4133 0.5497 0.7196 0.8196 0.9174
#> [11] 0.9570 0.9751 1.0000
#> attr(,"label")
#> [1] "Cumulative share of population"
#>
#>
#> $selected_lorenz
#> $selected_lorenz$for_dist
#> [1] "lq"
#>
#> $selected_lorenz$for_pov
#> [1] "lb"
#>
#> $selected_lorenz$use_lq_for_dist
#> [1] TRUE
#>
#> $selected_lorenz$use_lq_for_pov
#> [1] FALSE
#>
#>
#> $dist_stats
#> $dist_stats$popshare
#> [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
#>
#> $dist_stats$welfare_share_at
#> [1] 0.03911772 0.09067747 0.15263425 0.22412849 0.30507843 0.39614586
#> [7] 0.49903558 0.61752824 0.76157408 1.00000000
#>
#>
#> attr(,"class")
#> [1] "pipgd_params"