Methods for ''An accurate, fast, and scalable ecological inference algorithm for the R x C case''

Estimates the probability matrix for the R×C Ecological Inference problem using the Expectation-Maximization Algorithm with four approximation methods for the E-Step, and an exact method as well. It also provides a bootstrap function to estimate the standard deviation of the estimated probabilities. In addition, it has functions that aggregate rows optimally to have more reliable estimates in cases of having few data points. For comparing the probability estimates of two groups, a Wald test routine is implemented. The library has data from the first round of the Chilean Presidential Election 2021 and can also generate synthetic election data. Methods described in Ubilla Pavez, Pablo; Hermosilla, Daniel; Thraves, Charles (2026) ''An accurate, fast, and scalable ecological inference algorithm for the R×C case'', Statistics and Computing 36, Article 195 .


Methods for "An accurate, fast, and scalable ecological inference algorithm for the RxC case".

R-CMD-check-Windows R-CMD-check-macOS CRAN_Status_Badge

The following library includes a method (run_em) to solve the R×C Ecological Inference problem for the non-parametric case by using the EM algorithm with different approximation methods for the E-Step. Covariates are supported but not required. The standard deviation of the estimated probabilities can be computed using bootstrapping (bootstrap).

It also provides a function that generates synthetic election data (simulate_election) and a function that imports real election data (chilean_election_2021) from the Chilean first-round presidential election of 2021.

The setting in which the documentation presents the Ecological Inference problem is an election context where for a set of ballot-boxes we observe (i) the votes obtained by each candidate and (ii) the number of voters of each demographic group (for example, these can be defined by age ranges or sex). See Ubilla Pavez, P., Hermosilla, D. and Thraves, C. (2026): "An accurate, fast, and scalable ecological inference algorithm for the R×C case". Statistics and Computing, 36, Article 195..

The methods to compute the conditional probabilities of the E-Step included in this package are the following:

  • Markov Chain Monte Carlo (mcmc): Performs MCMC to sample vote outcomes for each ballot-box consistent with the observed data. This sample is used to estimate the conditional probability of the E-Step.

  • Multivariate Normal PDF (mvn_pdf): Uses the PDF of a Multivariate Normal to approxi- mate the conditional probability.

  • Multivariate Normal CDF (mvn_cdf): Uses the CDF of a Multivariate Normal to approxi- mate the conditional probability.

  • Multinomial (mult): A single Multinomial is used to approximate the sum of Multinomial distributions.

  • Exact (exact): Solves the E-Step exactly using the Total Probability Law, which requires enumerating an exponential number of terms.

On average, the Multinomial method is the most efficient and precise. Its precision matches the Exact method.

The documentation uses the following notation:

  • b: number of ballot boxes.
  • g: number of demographic groups.
  • c: number of candidates.
  • a: number of aggregated macro-groups.

To learn more about fastei, please consult the available vignettes:

browseVignettes("fastei")

Aditionally, it is possible to browse the full documentation on the library website.

Installation

It can either be installed from source by running devtools::install_github("DanielHermosilla/ecological-inference-elections) or by the CRAN repository install.packages("fastei"). Fortran support is required, usually, shipped by R itself.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("fastei")

0.0.21 by Daniel Hermosilla, 24 days ago


https://danielhermosilla.github.io/ecological-inference-elections/reference/fastei-package.html


Report a bug at https://github.com/DanielHermosilla/ecological-inference-elections/issues


Browse source code at https://github.com/cran/fastei


Authors: Charles Thraves [aut] , Pablo Ubilla [aut] , Daniel Hermosilla [aut, cre] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports Rcpp, jsonlite

Suggests knitr, rmarkdown, ggplot2, reshape2, viridis, dplyr, qpdf, testthat

Linking to Rcpp


See at CRAN