Bounded RAS / Biproportional Matrix Balancing with Cell-Level Constraints

Implements the RAS method for adjusting a matrix to match target row and column totals. In RAS, a matrix A is multiplied on the left by a diagonal matrix R and on the right by a diagonal matrix S, which gives the method its name. It is also known as biproportional matrix balancing, iterative proportional fitting (IPF) or raking. The package extends it with lower and upper bounds on individual cells. Provides several algorithmic variants for handling bound violations: hard cell-freezing with simultaneous, sequential, or hybrid fixation; two dependency-free clamp-and-compensate heuristics (proportional redistribution and iterative renormalization); and a naive unconstrained-recompute baseline; together with thin wrapper functions exposing equivalent bounded-calibration methods from the 'survey' package under a common interface. Intended for updating or regionalizing input-output tables, social accounting matrices (SAMs), and other applications where classic RAS/IPF is used but cell-level plausibility ranges must be respected. References: Deming and Stephan (1940) Deville, Saerndal and Sautory (1993) Acknowledgements: The author wishes to thank Conselleria de Educacion, Cultura y Universidades, Generalitat Valenciana (grant CIAICO/2023/031) for supporting this research.


RASbound

Bounded RAS (biproportional matrix balancing, also called iterative proportional fitting or raking) with lower and upper bounds on individual cells.

Classic RAS adjusts a seed matrix so that its row and column sums match given targets. RASbound adds cell-level bounds, for example when updating or regionalizing an input-output table and some cells must stay within a plausible range. If no matrix satisfies both the targets and the bounds, the functions say so, and tell you which rows and columns are involved.

Main functions

Function What it does
ras() Classic RAS, no bounds
bras_freeze_sim(), bras_freeze_seq(), bras_freeze_hybrid() Bounded RAS that solves, fixes violating cells at their bound, and repeats. Margins are matched exactly and bounds are respected. bras_freeze_hybrid() is the recommended default.
bras_naive(), bras_soft(), bras_cap_iter() Simpler reference methods, for comparison
bras_calibrate_logit(), bras_calibrate_linear(), bras_calibrate_raking() Wrappers around survey::calibrate() (need the survey and MASS packages)

All functions take the same arguments and return an object of class bras_fit.

Example

library(RASbound)

x0 <- matrix(c(2, 4, 6, 8), nrow = 2)
upper <- matrix(c(Inf, Inf, 12, Inf), nrow = 2)  # cap cell [1, 2] at 12

fit <- bras_freeze_hybrid(x0, row_targets = c(20, 20),
                          col_targets = c(15, 25), upper = upper)
fit
fit$matrix

Documentation

  • vignette("RASbound-intro"): introduction and choice of function.
  • vignette("RASbound-example"): a worked example with a real input-output-style table.
  • vignette("RASbound-diagnostics"): reading the results and diagnosing failures.

License

GPL-3. See LICENSE.md.

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("RASbound")

0.0.1 by Jose M. Pavía, 9 hours ago


https://github.com/JMPavia/RASbound


Report a bug at https://github.com/JMPavia/RASbound/issues


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


Authors: Jose M. Pavía [aut, cre] (ORCID:


Documentation:   PDF Manual  


GPL-3 license


Imports stats, graphics, grDevices, utils

Suggests survey, MASS, testthat, knitr, rmarkdown


See at CRAN