solveNonDecreasing {vtreat} | R Documentation |
Solve for best non-decreasing fit using isotone regression (from the "isotone" package https://CRAN.R-project.org/package=isotone).
Description
Return a vector of length y that is a function of x (differs at must where x differs) obeying the same order constraints as x. This vector is picked as close to y (by square-distance) as possible.
Usage
solveNonDecreasing(varName, x, y, w = NULL)
Arguments
varName |
character, name of variable |
x |
numeric, factor, or character input (not empty, no NAs). |
y |
numeric or castable to such (same length as x no NAs), output to match |
w |
numeric positive, same length as x (weights, can be NULL) |
Details
Please see https://github.com/WinVector/vtreat/blob/main/extras/MonotoneCoder.md.
Value
isotonicly adjusted y (non-decreasing)
Examples
if(requireNamespace("isotone", quietly = TRUE)) {
solveNonDecreasing('v', 1:3, c(1,2,1))
}
[Package vtreat version 1.6.4 Index]