Skip to contents

deal_run() holds one deal's premium, loss and deductions in each simulation of a shared simulation, and its inception in months from 1 January of the book's first year; deal_run_from_tower() takes them from a result of a tower, the amounts behind deal_ratios(), with each year's reinstatement premium added to the deposit (or swing-rated) premium unless reinstatement_premium = FALSE. deal_book() holds several deals: simulation j of every deal is the same year, so the book adds them without reordering.

Usage

deal_run(
  name,
  premium,
  loss,
  deductions = list(),
  outside_nmbf = character(),
  inception = 0,
  cashflows = NULL,
  terms = NULL,
  flows = NULL,
  funded = NULL,
  opening = NULL,
  patterns = NULL
)

deal_run_from_tower(
  name,
  tower,
  result,
  layer,
  inception = 0,
  cashflows = NULL,
  terms = NULL,
  flows = NULL,
  funded = NULL,
  opening = NULL,
  patterns = NULL,
  reinstatement_premium = TRUE
)

deal_book(deals)

book_names(book)

book_n_sims(book)

book_items(book)

book_select(book, names)

book_shift(book, name, inception)

book_amounts(book)

book_summary(book)

book_distribution(
  book,
  item,
  percentiles,
  tvar_levels = double(),
  sd_multiples = double(),
  quantile = "inverted_cdf",
  tvar = "exact",
  tail = "upper"
)

book_cashflows(
  book,
  rate = 0,
  lower = -0.95,
  upper = 1,
  points = 400L,
  bisections = 8L,
  newton_steps = 3L,
  extend = FALSE
)

book_calendar(book, start_year)

Arguments

name

The deal's name.

premium, loss

The deal's premium and loss, one a simulation.

deductions

A named list of deductions (commission, brokerage, a fee), each one amount a simulation.

outside_nmbf

Names of deductions that NMBF leaves out (a manager's fee).

inception

The month the deal incepts, from 1 January of the book's first year. It moves the deal's flows and patterns, not its losses.

cashflows

NULL, or a cashflow_run() of terms, one simulation for each of the deal's; the deal takes its flows and the terms' patterns.

terms

The cashflow_terms() of cashflows.

flows

NULL, or the investor's net flows from any model: a matrix with a row a simulation and a column a month from inception.

funded, opening

With flows, the capital paid in during the term and at inception, one a simulation.

patterns

NULL, or list(written, earned, paid), monthly cumulative shares from inception, for book_calendar().

tower

A reinsurance_tower.

result

A predictive_distribution from tower.

layer

The layer's or deal's name in tower.

reinstatement_premium

Whether each year's premium includes the reinstatement premium the tower computes for the year, pro rata as to amount and, where the layer says so, as to time (TRUE, the default), or is the deposit alone (FALSE, as deal_ratios() reads it).

deals

A list of deal_run()s.

book

A deal_book().

names

Deal names.

item

An item of book_amounts(): "premium", "loss", a deduction, "total_deductions", "nmbf" or "margin".

percentiles, tvar_levels, sd_multiples, quantile, tvar

The grid of statistics, as statistics().

tail

"upper", or "lower" to read low values as the risk, as for a margin.

rate

The annual rate the NPV discounts at, to month 0.

lower, upper, points, bisections, newton_steps, extend

The IRR's search, as irr(): from -95% to 100% a year by default, a simulation whose return is above the range flagged by root_above and found with extend = TRUE (or a larger upper).

start_year

The calendar year of book month 0.

Value

deal_run() and deal_run_from_tower() a deal_run; deal_book(), book_select() and book_shift() a deal_book; book_names() the deals' names in order, book_n_sims() the number of simulations and book_items() the items of book_amounts() (premium, loss, each deduction, total_deductions, nmbf and margin); book_amounts() a predictive_distribution with dimensions item and deal (the deals, then "total"); book_summary() a data frame of deal, item, mean and ratio; book_distribution() a list of total (named statistics) and contribution and marginal (matrices with a row a statistic and a column a deal); book_cashflows() a list of months, flows (a matrix, a row a simulation), mean_by_deal (a matrix, a column a deal), irr (a data frame as irr()), npv, moic and irr_by_deal (a list of data frames); book_calendar() a predictive_distribution with dimensions item, deal and year.

Details

book_amounts() gives every item of every deal and of the book in each simulation; book_summary() their means and ratios to the mean premium, the book's sums over sums. book_distribution() gives the book's statistics of an item with each deal's contribution at the book's ranks and its marginal effect (the book less the book without it). book_cashflows() moves each deal's investor flows to its inception and sums them, with the book's IRR, NPV and MOIC on the summed flows, and book_calendar() places premium, losses and flows in calendar years.

Examples

a <- deal_run("a", rep(100, 4), c(40, 80, 20, 160),
              deductions = list(brokerage = rep(2.5, 4)))
b <- deal_run("b", rep(300, 4), c(150, 330, 90, 210),
              deductions = list(brokerage = rep(7.5, 4)))
book <- deal_book(list(a, b))
book_summary(book)
#>     deal             item  mean ratio
#> 1      a          premium 100.0 1.000
#> 2      a             loss  75.0 0.750
#> 3      a        brokerage   2.5 0.025
#> 4      a total_deductions   2.5 0.025
#> 5      a             nmbf  22.5 0.225
#> 6      a           margin  22.5 0.225
#> 7      b          premium 300.0 1.000
#> 8      b             loss 195.0 0.650
#> 9      b        brokerage   7.5 0.025
#> 10     b total_deductions   7.5 0.025
#> 11     b             nmbf  97.5 0.325
#> 12     b           margin  97.5 0.325
#> 13 total          premium 400.0 1.000
#> 14 total             loss 270.0 0.675
#> 15 total        brokerage  10.0 0.025
#> 16 total total_deductions  10.0 0.025
#> 17 total             nmbf 120.0 0.300
#> 18 total           margin 120.0 0.300
book_distribution(book, "loss", 90, tvar_levels = 50)$contribution
#>                 a   b
#> Mean           75 195
#> Percentile 90  80 330
#> TVaR 50       120 270
a <- deal_run("a", rep(100, 4), c(40, 80, 20, 160),
              flows = matrix(c(-10, 0, 10.1), 4, 3, byrow = TRUE),
              funded = rep(0, 4), opening = rep(10, 4))
book_cashflows(deal_book(list(a)))$irr
#>         rate found npv sign_changes root_above root_below
#> 1 0.06152015  TRUE   0            1      FALSE      FALSE
#> 2 0.06152015  TRUE   0            1      FALSE      FALSE
#> 3 0.06152015  TRUE   0            1      FALSE      FALSE
#> 4 0.06152015  TRUE   0            1      FALSE      FALSE