Iterative proportional fitting to scale seed values to multiple target subtotals.

ip_fit_sl(datatable, targets, assumptions, datatable.value.name = "value",
  target.value.names = "value", assumption.value.names = c("value",
  "value_min", "value_max"), assumption.drop.names = c("Notes"),
  max.error = 0.01, max.iterations = 25, minmax.smash.param = 1/3,
  save.tars = FALSE, show.messages = TRUE)

Arguments

datatable

A data frame of values to be scaled to targets.

targets

A list of data frames containing subtotal targets for the datatable. All totals in each target should be equal.

assumptions

A single data frame containing data belonging to freeze_cells, freeze_slice, minmax_cells, and minmax_slice.

target.value.names

The names of the series in targets containing subtotals to scale. Can be string or array of strings.

assumption.value.names

The names of the series in assumptions containing subtotals to scale. Three item array of the freeze value name, min value, max value.

assumption.drop.names

The names of the series in assumptions to exclude from analysis. Usually columns containing notes.

max.error

The maximum total absolute difference allowed between final scaled values and targets. Iterative scaling will complete once the error is below this threshold or max.iterations occur.

max.iterations

The maximum number of iterations of scaling. Iterative scaling with end once this value is reached, even if the error is above max.error.

minmax.smash.param

Numeric value of 0 < x < 1. Following an out-of-bounds occurence for minmax_cells, the minmax.smash.param is the additional value added to the scaled value to bring it back into bounds. Values close to 0 bind the value to the violated bound, while close to 1 bind the value to the other bound. Values closer to 0 will require more iterations to complete.

datatable.value.names

The name of the series in datatable containing the values to be scaled.

Value

A dataframe with the same dimensionality as datatable, with all values scaled to the subtotals specified in each data frame in targets and meeting criteria supplied in assumptions.