@@ -37,18 +37,18 @@ trim_vec <- function(vec){
3737}
3838
3939# ' Calculate present value for a payoff with dynamic pricing and dynamic uptake
40- # '
40+ # '
4141# ' Present value of a payoff affected by dynamic pricing, with uptake across multiple cohorts (dynamic uptake)
4242# ' @param uptakes Vector of patient uptake over time
4343# ' @param horizon Time horizon for the calculation (length must be less than or equal to the length of payoffs)
4444# ' @param tzero Time at the date of calculation, to be used in lookup in prices vector
45- # ' @param payoffs Vector of payoffs of interest (numeric vector)
45+ # ' @param payoffs Vector of payoffs of interest (numeric vector)
4646# ' @param prices Vector of price indices through the time horizon of interest
4747# ' @param discrate Discount rate per timestep, corresponding to price index
4848# ' @param dpv_name Name to be given to Dynamic Present Value object created by this function call
4949# ' @returns A list containing `inputs` and `results`.
50- # ' The `inputs` list contains a list of the following parameters called with the function: `uptakes, payoffs, horizon, tzero, prices`, and `discrate`.
51- # ' The `results` output is a [class_dynpv()] S7 object that contains the following elements:
50+ # ' The `inputs` list contains a list of the following parameters called with the function: `uptakes, payoffs, horizon, tzero, prices`, and `discrate`.
51+ # ' The `results` output is a "dynpv" object (created by [class_dynpv()]) that contains the following elements:
5252# ' - `name`: Name given to the object
5353# ' - `df`: Tibble of calculation results
5454# ' - `ncoh`: Number of cohorts of uptaking patients
@@ -66,19 +66,19 @@ trim_vec <- function(vec){
6666# ' payoffs = c("cost_daq_new", "cost_total", "qaly"),
6767# ' discount = "disc"
6868# ' )
69- # '
69+ # '
7070# ' # Obtain short payoff vector of interest
7171# ' payoffs <- democe |>
7272# ' dplyr::filter(int=="new", model_time<11) |>
7373# ' dplyr::mutate(cost_oth = cost_total - cost_daq_new)
7474# ' Nt <- nrow(payoffs)
75- # '
75+ # '
7676# ' # Example calculation
7777# ' dynpv(
7878# ' uptakes = rep(1, Nt),
7979# ' payoffs = payoffs$cost_oth,
8080# ' prices = 1 + (0:(Nt-1))*0.05,
81- # ' discrate = 0.08
81+ # ' discrate = 0.08
8282# ' )
8383dynpv <- function (
8484 uptakes = 1 ,
@@ -106,9 +106,10 @@ dynpv <- function(
106106 v = (1 + discrate )^ (1 - t ),
107107 pv = uj * pk * R * v
108108 )
109+
109110 # Put dataset into a dynpv_class object
110- cds <- class_dynpv(name = dpv_name , df = df )
111- # Return
111+ cds <- class_dynpv(name = dpv_name , df = df )
112+
112113 return (list (
113114 inputs = list (
114115 uptakes = uptakes ,
0 commit comments