Protect Function Evaluations
Ensures non-failure and possibly finite-ness of a function evaluation.
Value that will be used as on failure of
protect returns a function with arguments
... arguments are all passed through to the underlying
fail.value contains the value to return in
the event of a failure (e.g., an error occuring). If
fail.value is also returned where the value
NaN or infinite.
Some functions, such as
optim with method
L-BFGS-B (and therefore
find.mle), require that
every value is finite. Optimisation with these functions also
requires that the target functions to not generate errors.
protect catches these issues, returning the value of
No check is made that
f returns a single value, but it should.
Richard G. FitzJohn
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.