Adjust a table by multiplying rows and columns in order to reproduce the provided margins, preserving all the odds ratios. This procedure is know as the RAS or Deming-Stephan algorithm, as iterative proportional fitting (IPF) or as biproportional fitting.
ras(tab, row, col, tolerance = .Machine$double.eps)
a two-way table with only positive or zero entries
a vector of strictly positive elements containing the wanted row margins (sums).
a vector of strictly positive elements containing the wanted column margins (sums).
the convergence criterion to stop iterating.
The adjusted table with row sums equal to row
and column sums equal to col
.
Note that sum(row)
must be equal to sum(col)
for the algorithm to make sense.