Return metrics on simulated cash flows
npv.Rdnpv() discounts each simulation's flows at an annual rate,
sum(x * (1 + rate)^-t). irr() finds the annual rate at which they are
worth 0: their value on a grid of points rates from lower to upper,
the sign change (or exact zero) whose bracket's midpoint is nearest 0,
bisections halvings of that bracket and newton_steps Newton steps
clipped to it. A simulation with no root in the range has found
FALSE and NaN, with root_above (or root_below) TRUE when a root
lies outside the range, a return above 100% a year under the defaults,
and FALSE for flows with no root at all, such as flows of one sign;
extend = TRUE searches beyond the range for it. One with several roots
has sign_changes above 1. The defaults are a reference simulation
model's, with no search beyond the range.
Usage
npv(flows, times, rate, unit = "years")
irr(
flows,
times,
unit = "years",
lower = -0.95,
upper = 1,
points = 400L,
bisections = 8L,
newton_steps = 3L,
extend = FALSE
)
moic(released, funded, opening)
leverage(rate, premium, funded, opening)
tiered_fee(margins, breakpoints, slopes)Arguments
- flows
One simulation's flows a row of a matrix, one column a time, or a vector for one simulation.
- times
The time of each column, in
unitfrom the start.- rate
Annual effective rate, above -1; for
leverage(), the rate applied to premium.- unit
"years","months"(a twelfth of a year) or"days"(actual/365).- lower, upper
The range of rates searched.
- points, bisections, newton_steps
The grid's size and the refinement steps.
- extend
When no root is in the range but one lies beyond it, search for it (above
upperby doubling1 + rate, belowlowerby halving it).- released
Equity released over the term.
- funded
Capital funded during the term.
- opening
Capital held at the start.
Written premium.
- margins
The margins the fee is charged on.
- breakpoints
Strictly increasing; the first is the floor.
- slopes
One a breakpoint, the slope of the tier that starts there.
Value
npv(), moic(), leverage() and tiered_fee() a numeric
vector; irr() a data frame with rate, found, npv (at the rate),
sign_changes, root_above and root_below, one row a simulation.
Details
moic() is the multiple on invested capital,
1 + released / (funded + opening), and leverage() the leverage of
written premium on capital, rate * premium / (funded + opening), the
rate the caller's. tiered_fee() charges slope slopes[i] on the part of
each margin between breakpoints[i] and breakpoints[i + 1], the last
tier unbounded and nothing below the first breakpoint.
Examples
flows <- rbind(c(-100, 0, 121), c(-100, 230, -132), c(10, 5, 1))
irr(flows, c(0, 1, 2))
#> rate found npv sign_changes root_above root_below
#> 1 0.1 TRUE -1.421085e-14 1 FALSE FALSE
#> 2 0.1 TRUE -1.421085e-14 2 FALSE FALSE
#> 3 NaN FALSE NaN 0 FALSE FALSE
# A return of 300%, above the default range: flagged, and found on request.
irr(c(-100, 400), c(0, 1))
#> rate found npv sign_changes root_above root_below
#> 1 NaN FALSE NaN 0 TRUE FALSE
irr(c(-100, 400), c(0, 1), extend = TRUE)$rate
#> [1] 3
npv(flows, c(0, 1, 2), 0.1)
#> [1] -1.421085e-14 1.421085e-14 1.537190e+01
irr(c(-100, 0, 0, 103), c(0, 31, 59, 90), unit = "days")$rate
#> [1] 0.1273586
moic(30, 40, 60)
#> [1] 1.3
leverage(0.5, 300, 50, 100)
#> [1] 1
tiered_fee(c(3, 10, 25), c(5, 15), c(0.1, 0.2))
#> [1] 0.0 0.5 3.0