Skip to contents

Estimates ratio of quantiles (e.g., P90/P10) on simple and complex sampling data

Usage

ratio_quantiles(
  y,
  weights = NULL,
  prob_numerator = 0.9,
  prob_denominator = 0.1,
  type = 6,
  na.rm = FALSE
)

Arguments

y

A numeric vector of data values

weights

A numeric vector of sampling weights (optional)

prob_numerator

The percentile to be considered at the numerator (default 0.90)

prob_denominator

The percentile to be considered at the denominator (default 0.10

type

Quantile estimation type: integer 4-9 or HD for Harrell-Davis (default: 6). See csquantile documentation for a complete description.

na.rm

Logical, should missing values be removed? (default: TRUE)

Value

A scalar numeric value representing the estimated ratio of quantiles

Details

Consider a random sample \(s\) of size \(n\), and let \(w_j\), \(j \in s\), define the sampling weight and \(y_j\) be the observed characteristics (i.e. income) associated to the \(j\)-th individual, \(j = 1, \ldots, n\). Let \(p_{top}\) be the order of the quantile at the numerator and \(p_{bottom}\) be the order of the quantile at the denominator. For example, set \(p_{top} = 0.90\) and \(p_{bottom} = 0.10\). Then the popular P90/P10 ratio can be estimated by

$$\widehat{{P}90/{P}10} = \frac{\widehat{Q}(p=0.9)}{\widehat{Q}(p=0.1)} $$

where the estimated quantiles \(\widehat{Q}(p)\) are computed via the function csquantile(), which accounts for sampling weights and the specified quantile type.

See also

Other inequality indicators based on quantiles: inequantiles(), palma_ratio(), plot_inequality_curve(), qri(), qsr()

Examples


data(synthouse)

eq <- synthouse$eq_income ### Income data

# Compute unweighted P90/P10 with default type 6 quantile estimator
ratio_quantiles(y = eq)
#>  P90/P10 
#> 5.712946 

# Consider the sampling weights, change quantile estimation type and orders of quantiles
w <- synthouse$weight
ratio_quantiles(y = eq, weights = w, prob_numerator = 0.6, prob_denominator = 0.1, type = 5)
#>  P60/P10 
#> 2.953968 

# Compare the P90/P10 across macro-regions (NUTS1)
tapply(1:nrow(synthouse), synthouse$NUTS1, function(area) {
  ratio_quantiles(y = synthouse$eq_income[area],
      weights = synthouse$weight[area])
})
#>        C        N       NE       NO        S 
#> 6.267395 5.595916 5.961529 6.278178 5.401721