Description Usage Arguments Value
View source: R/combine_distributions.R
Combines two distributions fitted with inequalityTools by weighted summing their PDFs. Then recalculates the other distribution functions (pdf, cdf, quantile function, and Lorenz Curve) and descriptives.
1 2 3 4 5 6 7 8 9 10 | combine_distributions(
fit1,
fit2,
n1,
n2,
quadrature_precision = 5000,
points_to_adjust = 2000,
upper_limit = 1e+05,
upper_p_limit = 0.9995
)
|
fit1 |
A interpolated distribution fitted with tableFit_nonParametric or tableFit_gb2 |
fit2 |
Another interpolated distribution fitted with tableFit_nonParametric or tableFit_gb2 |
n1 |
The number of observations or proportion of the fit1. |
n2 |
The number of observations or proportion of the fit2. |
quadrature_precision |
Gauss-Legendre Quadrature level - argument to be passed to mvQuad::createNIGrid. Default to 5e3 |
points_to_adjust |
The number of points from which the cdf, quantile function and Lorenz Curve will be calculated. Default to 2000 |
upper_limit |
The maximum income value of the distribution support. Default to 1e5 |
upper_p_limit |
A cumulative probability value which will be taken as the maximum for the quantile function. After it, quantile function will be top coded. Default to .9995 |
Returns a list with the following components
\descriptive A tibble with two columns: estMean (the distribution mean), gini (the Gini Coefficient, if gini = TRUE
, NA otherwise)
\pdf The PDF function. Takes values as input and returns probability densities.
\cdf The CDF function. Takes values as input and returns cumulative probabilities.
\quantile The Quantile function. Takes cumulative probabilities as input and returns quantile values as outputs.
\lorenz The Lorenz Curve function. Takes cumulative probabilities as input and returns the proportion of income accumulated at the quantile.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.