voiage.core.utils.calculate_net_benefit
calculate_net_benefit
Section titled “calculate_net_benefit”calculate_net_benefit([positional or keyword] costs: np.ndarray = None, [positional or keyword] effects: np.ndarray = None, [positional or keyword] wtp: float | np.ndarray = None) -> np.ndarrayCalculate net monetary benefit (NMB).
NMB = (effects * wtp) - costs. Supports scalar or array WTP for threshold analysis.
Args:
costs (np.ndarray): Array of costs. Shape (n_samples, n_strategies) or (n_samples,).
effects (np.ndarray): Array of effects (e.g., QALYs). Shape (n_samples, n_strategies) or (n_samples,).
Must match the shape of costs.
wtp (Union[float, np.ndarray]): Willingness-to-pay threshold.
- If float: scalar WTP applied to all.
- If np.ndarray: WTP values, e.g., for different thresholds or time points. Broadcasting rules apply. If WTP is an array, its shape should be compatible for broadcasting with effects and costs. E.g., (n_wtp_thresholds,) or (n_samples, n_wtp_thresholds).
Returns
Section titled “Returns”np.ndarray: Array of net monetary benefits. Shape will depend on broadcasting with WTP. If WTP is scalar, shape matches costs/effects. If WTP is (k,), NMB shape will be (n_samples, n_strategies, k) or (n_samples, k).
Raises
Section titled “Raises”DimensionMismatchError: If shapes of costs and effects are incompatible. InputError: If inputs are not valid NumPy arrays or WTP is invalid.
Parameters:
costsnp.ndarrayeffectsnp.ndarraywtpfloat | np.ndarray
Returns: np.ndarray