R/dynamic.R
dynpv.Rd
Present value of a payoff affected by dynamic pricing, with uptake across multiple cohorts (dynamic uptake)
Vector of patient uptake over time
Vector of payoffs of interest (numeric vector)
Time horizon for the calculation (length must be less than or equal to the length of payoffs)
Time at the date of calculation, to be used in lookup in prices vector
Vector of price indices through the time horizon of interest
Discount rate per timestep, corresponding to price index
Two lists named inputs
and results
.
The inputs
list contains a list of the following parameters called with the function: uptakes, payoffs, horizon, tzero, prices
, and discrate
.
The results
list contains the following elements:
ncoh
: Number of cohorts of uptaking patients
uptake
: Total number of uptaking patients
calc
: Tibble of calculation results
cohpv
: Tibble of summarized calculation results for each uptake cohort
total
: Total present value
mean
: Average present value per uptaking patient (=total/uptake)
# Obtain dataset
democe <- get_dynfields(
heemodel = oncpsm,
payoffs = c("cost_daq_new", "cost_total", "qaly"),
discount = "disc"
)
# Obtain short payoff vector of interest
payoffs <- democe |>
dplyr::filter(int=="new", model_time<11) |>
dplyr::mutate(cost_oth = cost_total - cost_daq_new)
Nt <- nrow(payoffs)
# Example calculation
dynpv(
uptakes = rep(1, Nt),
payoffs = payoffs$cost_oth,
prices = 1 + (0:(Nt-1))*0.05,
discrate = 0.08
)
#> $inputs
#> $inputs$uptakes
#> [1] 1 1 1 1 1 1 1 1 1 1
#>
#> $inputs$payoffs
#> [1] 354.8228 354.3419 353.7327 352.9161 351.8567 350.5507 349.0109 347.2584
#> [9] 345.3166 343.2095
#>
#> $inputs$horizon
#> [1] 10
#>
#> $inputs$tzero
#> [1] 0
#>
#> $inputs$prices
#> [1] 1.00 1.05 1.10 1.15 1.20 1.25 1.30 1.35 1.40 1.45
#>
#> $inputs$discrate
#> [1] 0.08
#>
#>
#> $results
#> $results$ncoh
#> [1] 10
#>
#> $results$uptake
#> [1] 10
#>
#> $results$calc
#> # A tibble: 55 × 9
#> j k l t uj pk R v pv
#> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 1 0 1 1 355. 1 1 355.
#> 2 1 2 0 2 1 354. 1.05 0.926 344.
#> 3 1 3 0 3 1 354. 1.1 0.857 334.
#> 4 1 4 0 4 1 353. 1.15 0.794 322.
#> 5 1 5 0 5 1 352. 1.2 0.735 310.
#> 6 1 6 0 6 1 351. 1.25 0.681 298.
#> 7 1 7 0 7 1 349. 1.3 0.630 286.
#> 8 1 8 0 8 1 347. 1.35 0.583 274.
#> 9 1 9 0 9 1 345. 1.4 0.540 261.
#> 10 1 10 0 10 1 343. 1.45 0.500 249.
#> # ℹ 45 more rows
#>
#> $results$cohpv
#> # A tibble: 10 × 3
#> j tzero spv
#> <int> <dbl> <dbl>
#> 1 1 0 3033.
#> 2 2 0 2688.
#> 3 3 0 2351.
#> 4 4 0 2022.
#> 5 5 0 1703.
#> 6 6 0 1393.
#> 7 7 0 1093.
#> 8 8 0 804.
#> 9 9 0 525.
#> 10 10 0 257.
#>
#> $results$total
#> [1] 15869.53
#>
#> $results$mean
#> [1] 1586.953
#>
#>