combine_distributions: Combines two different distributions that were fitted using...

Description Usage Arguments Value

View source: R/combine_distributions.R

Description

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.

Usage

 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
)

Arguments

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

Value

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.


antrologos/inequalityTools documentation built on May 23, 2021, 11:56 a.m.