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.
WIPF1(
seed,
weights,
margin = 1,
normalize = TRUE,
tol = 10^-6,
maxit = 1000,
full = FALSE,
...
)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:
An object similar to seed with the solution reached at convergence (or when the maximum number of iterations is reached).
Number of iterations when the algorithm stops.
An object similar to margin with the absolute differences between the values in margin and
the weighted sum of the values in sol.
A list containing all the objects with the values used as arguments by the function.
A vector of non-negative values with the initial values.
A vector of non-negative values with the weights associated to each component of seed and with the same length as seed.
A non-negative scalar with the (weighted) marginal total to be fitted. Default, 1.
TRUE/FALSE argument indicating whether weights should be normalized
to sum 1 before building the weighted sum to be compared with the margin value.
Default, TRUE. Normalization is necessary when we want to adjust a set of indexes
for which the margin correspond to other index that is a theoretical convex
combination of the inner indexes. This characterizes a typical context where WIPF could be of value.
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 tol.
Default, 0.000001.
Stopping criterion. A positive integer number indicating the maximum number of iterations
allowed. Default, 1000. The algorithm will stop if the values to be fitted still has not
converged after this many iterations.
TRUE/FALSE argument indicating if either only the solution should be shown or
a more complete output.
Other arguments to be passed to the function. Not currently used.
Jose M. Pavia, pavia@uv.es
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)
Run the code above in your browser using DataLab