Defining utilities for events and interventions

add_util(.data = NULL, util, evt, trt, cycle_l = NULL, cycle_starttime = 0)

Arguments

.data

Existing utility data

util

Value or expression to calculate the utility estimate

evt

Events for which this utility is applicable

trt

Interventions for which this utility is applicable

cycle_l

Cycle length; only needed if utilities are calculated per cycle

cycle_starttime

Cycle when utilities start being accrued; only needed if utilities are calculated per cycle

Value

A list of utilities

Details

Utilities can be defined by writing expressions and objects in the cost argument whose execution will be delayed until the model runs.

This function accepts the use of pipes (%>%) to define multiple utilities.

Examples

add_util(evt = c("start","idfs","ttot"),
trt = c("int", "noint"),
util = util.idfs.ontx * fl.idfs.ontx + util.idfs.offtx * (1-fl.idfs.ontx))
#> $start_int
#> $start_int$util
#> util.idfs.ontx * fl.idfs.ontx + util.idfs.offtx * (1 - fl.idfs.ontx)
#> 
#> $start_int$cycle_l
#> NULL
#> 
#> $start_int$cycle_starttime
#> [1] 0
#> 
#> 
#> $idfs_int
#> $idfs_int$util
#> util.idfs.ontx * fl.idfs.ontx + util.idfs.offtx * (1 - fl.idfs.ontx)
#> 
#> $idfs_int$cycle_l
#> NULL
#> 
#> $idfs_int$cycle_starttime
#> [1] 0
#> 
#> 
#> $ttot_int
#> $ttot_int$util
#> util.idfs.ontx * fl.idfs.ontx + util.idfs.offtx * (1 - fl.idfs.ontx)
#> 
#> $ttot_int$cycle_l
#> NULL
#> 
#> $ttot_int$cycle_starttime
#> [1] 0
#> 
#> 
#> $start_noint
#> $start_noint$util
#> util.idfs.ontx * fl.idfs.ontx + util.idfs.offtx * (1 - fl.idfs.ontx)
#> 
#> $start_noint$cycle_l
#> NULL
#> 
#> $start_noint$cycle_starttime
#> [1] 0
#> 
#> 
#> $idfs_noint
#> $idfs_noint$util
#> util.idfs.ontx * fl.idfs.ontx + util.idfs.offtx * (1 - fl.idfs.ontx)
#> 
#> $idfs_noint$cycle_l
#> NULL
#> 
#> $idfs_noint$cycle_starttime
#> [1] 0
#> 
#> 
#> $ttot_noint
#> $ttot_noint$util
#> util.idfs.ontx * fl.idfs.ontx + util.idfs.offtx * (1 - fl.idfs.ontx)
#> 
#> $ttot_noint$cycle_l
#> NULL
#> 
#> $ttot_noint$cycle_starttime
#> [1] 0
#> 
#>