Learn R Programming

⚠️There's a newer version (2.3.1) of this package.Take me there.

humanleague

humanleague is a python and an R package for microsynthesising populations from marginal and (optionally) seed data. The core code is implemented in C++, and the current release is version 2.

The package contains algorithms that use a number of different microsynthesis techniques:

The latter provides a bridge between deterministic reweighting and combinatorial optimisation, offering advantages of both techniques:

  • generates high-entropy integral populations
  • can be used to generate multiple populations for sensitivity analysis
  • goes some way to address the 'empty cells' issues that can occur in straight IPF
  • relatively fast compuation time

The algorithms:

  • support arbitrary dimensionality* for both the marginals and the seed.
  • produce statistical data to ascertain the likelihood/degeneracy of the population (where appropriate).

[* excluding the legacy functions retained for backward compatibility with version 1.0.1]

The package also contains the following utility functions:

  • a Sobol sequence generator
  • functionality to convert fractional to nearest-integer marginals (in 1D). This can also be achieved in multiple dimensions by using the QISI algorithm.
  • functionality to 'flatten' a population into a table: this converts a multidimensional array containing the population count for each state into a table listing individuals and their characteristics.

Version 1.0.1 reflects the work described in the Quasirandom Integer Sampling (QIS) paper.

R installation

> devtools::install_github("virgesmith/humanleague")

Or, for the previous version

> devtools::install_github("virgesmith/humanleague@1.0.1")

python installation

Requires Python 3, with numpy installed

pip install git+https://github.com/virgesmith/humanleague.git@master

Build and test (from local repo)

user@host:~/dev/humanleague/python$ ./setup.py test

Install (from local repo)

user@host:~/dev/humanleague/python$ ./setup.py install

The latter command may require admin rights. On linux, sudo is unnecessary if you have group (e.g. staff) write access to /usr/local/lib.

Examples

Consult the package documentation, e.g.

> library(humanleague)
> ?humanleague

in R, or for python:

>>> import humanleague as hl
>>> help(hl)

Copy Link

Version

Install

install.packages('humanleague')

Monthly Downloads

696

Version

2.0.2

License

MIT + file LICENCE

Maintainer

Andrew Smith

Last Published

December 14th, 2017

Functions in humanleague (2.0.2)

flatten

Convert multidimensional array of counts per state into table form. Each row in the table corresponds to one individual
synthPop

[Legacy] Generate a population in n dimensions given n 1-d marginals.
ipf

Multidimensional IPF
humanleague

humanleague
qisi

QIS-IPF
sobolSequence

Generate Sobol' quasirandom sequence
prob2IntFreq

Generate integer frequencies from discrete probabilities and an overall population.
synthPopG

[Legacy] Generate a population in 2 dimensions given 2 1-d marginals and a further constraint.
unitTest

Entry point to enable running unit tests within R (e.g. in testthat)
qis

Multidimensional QIS