Iterative proportional fitting to scale seed values to multiple target subtotals.
ip_fit(datatable, targets, datatable.value.name = "value", target.value.names = "value", max.error = 0.01, max.iterations = 25, freeze_cells = NULL, freeze_cells.value.name = "value", freeze_slice = NULL, freeze_slice.value.names = "value", minmax_cells = NULL, minmax_cells.value.names = c("value_min", "value_max"), minmax_slice = NULL, minmax_slice.value.names = c("value_min", "value_max"), minmax.smash.param = 1/3, growth_targets = NULL, save.tars = FALSE, show.messages = TRUE)
datatable | A data frame of values to be scaled to targets. |
---|---|
targets | A list of data frames containing subtotal targets for the |
target.value.names | The names of the series in |
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 | The maximum number of iterations of scaling. Iterative scaling with end once this value is reached, even if the error is above |
freeze_cells | Optional data frame of values with same series columns as |
freeze_cells.value.name | The name of the series of iced values in |
freeze_slice | Optional data frame containing subtotal targets for the |
minmax_cells | Optional data frame of values with same series columns as |
minmax_cells.value.names | An array of length 2 of the names of the minimum and maximum values in |
minmax_slice | Optional data frame containing subtotal targets for the |
minmax.smash.param | Numeric value of 0 < x < 1. Following an out-of-bounds occurence for |
growth_targets | A data frame of cell or slice targets with growth rates over listed dimensions. See |
datatable.value.names | The name of the series in |
freeze_slice.value.name | The name or names of the series of iced values in |
minmax_slice.value.name | The name or names of the series of the minimum and maximum values in |
A dataframe with the same dimensionality as datatable
, with all values scaled to the subtotals specified in each data frame in targets
.
tar1 <- data.frame(x = letters[1:2], value = c(50, 50)) tar2 <- data.frame(y = letters[3:5], value = c(20, 40, 40)) tar3 <- data.frame(z = letters[6:10], value = c(10, 20, 30, 40, 10)) tar.list <- list(tar1, tar2, tar3) df <- ip_create_seed(tar.list) %>% ip_fit(tar.list)#>#>#> Warning: Column `x` joining character vector and factor, coercing into character vector#> Warning: Column `y` joining character vector and factor, coercing into character vector#> Warning: Column `z` joining character vector and factor, coercing into character vector#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>#>