Softly enforces nonnegativity of a numeric weight vector. Large negative values are treated as errors, while small negative values are truncated to zero.
enforce_nonneg_weights(weights, tol = 1e-08)A list with components:
oklogical; TRUE if no clearly negative weights
were found.
messagecharacter; diagnostic message when ok is
FALSE, otherwise NULL.
weightsnumeric vector of adjusted weights (original if
ok is FALSE, otherwise with small negatives clipped to
zero).
numeric vector of weights.
numeric tolerance below which negative values are treated as numerical noise and clipped to zero.
Values below -tol are treated as clearly negative. Values in
[-tol, 0) are clipped to zero.