WIPF1 {WIPF} | R Documentation |
Weighted Iterative Proportional Fitting (WIPF) in one dimension
Description
Implements WIPF in one dimension. This function updates, using a set of weights, an initial 1-dimensional array, a vector (referred as the seed), to match a given value (referred as the margin), in such as way that the weighted sum of the updated values coincide with the margin.
Usage
WIPF1(
seed,
weights,
margin = 1,
normalize = TRUE,
tol = 10^-6,
maxit = 1000,
full = FALSE,
...
)
Arguments
seed |
A vector of non-negative values with the initial values. |
weights |
A vector of non-negative values with the weights associated to each component of |
margin |
A non-negative scalar with the (weighted) marginal total to be fitted. Default, |
normalize |
|
tol |
Stopping criterion. The algorithm stops when the maximum absolute difference between
the solutions obtained in two consecutive iteration is lower than the value specified by |
maxit |
Stopping criterion. A positive integer number indicating the maximum number of iterations
allowed. Default, |
full |
|
... |
Other arguments to be passed to the function. Not currently used. |
Value
When full = FALSE
an object similar to seed
with the solution reached when the algorithm stops.
When full = TRUE
a list with the following components:
sol |
An object similar to |
iter |
Number of iterations when the algorithm stops. |
error.margins |
An object similar to |
inputs |
A list containing all the objects with the values used as arguments by the function. |
Note
Weighted Iterative proportional fitting is an extension of IPF. WIPF produces the same solutions than IPF with all weights being ones and when they are not normalized. IPF is also known as RAS in economics, raking in survey research or matrix scaling in computer science.
Author(s)
Jose M. Pavia, pavia@uv.es
Examples
s <- c(1.0595723, 0.9754876, 0.8589494, 0.8589123)
w <- c(651301.9, 581185.1, 555610.8, 602595.6)
example <- WIPF1(seed = s, weights = w)