| irr_safe | R Documentation |
Computes a real IRR from a vector of dated cash flows t = 0, \dots, T.
The algorithm first searches for a root in an initial interval
[lower, upper]. If this interval does not bracket a root
(that is, if the net present value function does not change sign),
the upper bound is expanded multiplicatively up to max_upper.
If the cash-flow series exhibits no sign change (all flows are
>= 0 or all <= 0), or if no root can be bracketed after
expansion, the function silently returns NA_real_ (optionally
with a warning if warn = TRUE).
irr_safe(
cf,
lower = -0.9999,
upper = 0.1,
max_upper = 10000,
tol = sqrt(.Machine$double.eps),
warn = FALSE
)
cf |
Numeric. Vector of cash flows |
lower, upper |
Initial search bounds for the IRR (decimal rates). |
max_upper |
Maximum upper bound when automatically expanding the bracketing interval. |
tol |
Numerical tolerance passed to |
warn |
Logical. If |
A numeric scalar (decimal rate) corresponding to the IRR, or
NA_real_ if the IRR is not defined or could not be located
numerically.
irr_safe(c(-100, 60, 60)) # IRR defined
irr_safe(c(-100, -20, -5)) # no sign change -> NA
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.