Skip to contents

Vectorized CBA evaluation model computing avoided damages, expected annual benefit (EAD avoided), and net present value (NPV) for a matrix of sampled parameters.

Usage

sa_model(
  x,
  impact_base,
  calendar,
  rate = getOption("floodam.cba")[["rate"]],
  indicator = c("complete", "npv", "benefit")
)

Arguments

x

A numeric matrix or data frame whose columns contain sampled parameter values (cost_*, period_*, hydraulic_*, impact_*).

impact_base

A named numeric vector of baseline avoided damages per stake and flood scenario, as returned by sa_set_impact_base().

calendar

A data frame representing the project's normalized calendar schedule, containing at least columns year, benefit, and action cost schedules (as returned by sa_input[["calendar"]]).

rate

Discount rate specification (defaults to getOption("floodam.cba")[["rate"]]).

indicator

Character scalar specifying the output format: "complete" (default) returns parameters, damages, benefit, and npv; "npv" returns only the numeric vector of NPV values; "benefit" returns only the numeric vector of expected annual benefits.

Value

Depending on indicator:

  • If "complete", an invisible numeric matrix combining x, avoided damages per stake/scenario, benefit, and npv.

  • If "npv", an invisible numeric vector of Net Present Values corresponding to each row of x.

  • If "benefit", an invisible numeric vector of expected annual benefits corresponding to each row of x.

Details

This function serves as the computational core for sensitivity and uncertainty analysis, designed to be called directly or passed as the model argument to functions from the sensitivity package.

Given a parameter matrix x where columns correspond to:

  • investment and maintenance costs (cost_*),

  • flood hazard return periods (period_*),

  • hydraulic efficiency (hydraulic_*),

  • damage multipliers (impact_*),

the function executes the following steps for each row:

  1. Avoided damages per stake and flood event are scaled via sa_fit_impact() using impact_base.

  2. Integration weights across flood events are computed using calculate_weight() from return periods.

  3. Expected annual benefit (EAD avoided) is computed by integrating avoided damages across flood probabilities via trapezoidal summation.

  4. Annual discount weights are evaluated using discount_weight() on calendar[["year"]] with discount rate.

  5. Pre-discounted schedule coefficients are combined with benefits and costs to compute Net Present Value (npv) through matrix multiplication.

Author

Frédéric Grelot, frederic.grelot.1994_cran@m4x.org