Skip to main content

binsmooth - Better Estimates from Binned Income Data.

Project description

binsmooth

Build Status

Python implementation of "Better Estimates from Binned Income Data"

Better Estimates from Binned Income Data: Interpolated CDFs and Mean-Matching
Paul T. von Hippel, David J. Hunter, McKalie Drown
Sociological Science
Volume 4, Number 26, Pages 641-655
2017

Originally implemented in the R package binsmooth.

Usage

from binsmooth import BinSmooth

bin_edges = np.array([0, 18200, 37000, 87000, 180000])
counts = np.array([0, 7527, 13797, 75481, 50646, 803])

bs = BinSmooth()
bs.fit(bin_edges, counts)

# Print median estimate
print(bs.inv_cdf(0.5))

Improvements

Better tail estimate by using scipy's fmin to perform automatic optimisation rather than the adhoc search method found in the R implementation.

More precise inverse CDF by dynamically sampling the CDF. This is done by sampling more densely in areas where the CDF is steeper and less in flatter areas, rather than evenly spaced sampling.

Warnings

Results will be different to the original R implementation due to differences in spline implementation between R's splinefun and scipy's PchipInterpolator.

Accuracy is highly dependent on the mean of the distribution. If you do not supply a mean, then one will be estimated in an adhoc manner and the accuracy of estimates may be poor.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

binsmooth-0.11.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

binsmooth-0.11-py2.py3-none-any.whl (5.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file binsmooth-0.11.tar.gz.

File metadata

  • Download URL: binsmooth-0.11.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for binsmooth-0.11.tar.gz
Algorithm Hash digest
SHA256 915391b07d45d7e5edbef7ce59607aa9c458bc08f6f5247280df378d239b5890
MD5 2d199e53663f17c49ee7eba4a8acbfb6
BLAKE2b-256 769f93c3eeb2525f21841d64dd643a98adce5b062fff077f6ae244f16a943e83

See more details on using hashes here.

File details

Details for the file binsmooth-0.11-py2.py3-none-any.whl.

File metadata

  • Download URL: binsmooth-0.11-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for binsmooth-0.11-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 060061ac807720d6133a59e2cbe3a3436aa046c406b2b1ab7712bc6c4b0e13ba
MD5 be07e4feea2a5af7261602bf02a05fe1
BLAKE2b-256 f531049a1b6a6614dc30a67a69c3a53fe65936406936841e53238a4a9cd9a1d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page