Simulate values (i.e., utility or costs) associated with health states in a state transition or partitioned survival model.

## Public fields

params

Parameters for simulating state values. Currently supports objects of class tparams_mean or params_lm.

input_data

An object of class input_mats. Only used for params_lm objects.

method

The method used to simulate costs and quality-adjusted life-years (QALYs) as a function of state values. If wlos, then costs and QALYs are simulated by weighting state values by the length of stay in a health state. If starting, then state values represent a one-time value that occurs when a patient enters a health state. When starting is used in a cohort model, the state values only accrue at time 0; in contrast, in an individual-level model, state values accrue each time a patient enters a new state and are discounted based on time of entrance into that state.

time_reset

If FALSE then time intervals are based on time since the start of the simulation. If TRUE, then time intervals reset each time a patient enters a new health state. This is relevant if, for example, costs vary over time within health states. Only used if method = wlos.

## Methods

### Method new()

Create a new StateVals object.

#### Arguments

t

A numeric vector of times.

type

"predict" for mean values or "random" for random samples.

#### Returns

A data.table of simulated state values with columns for sample, strategy_id, patient_id, state_id, time, and value.

### Method check()

Input validation for class. Checks that fields are the correct type.

#### Arguments

deep

Whether to make a deep clone.

## Examples

# Simple sick-sicker example where drug costs vary by treatment strategy
# and over time. Prior to time = 5, costs are $10,000 for treatment strategy # 1 and$5,000 for treatment strategy 2. After time = 5, costs are $2,000 # for both treatment strategies ## Setup the model hesim_dat <- hesim_data( strategies = data.frame(strategy_id = c(1, 2)), patients = data.frame(patient_id = 1:3), states = data.frame(state_id = c(1, 2), # Non-death states state_name = c("sick", "sicker")) ) ## Drug costs vary by health state and time interval drugcost_tbl <- stateval_tbl( data.frame( strategy_id = c(1, 1, 2, 2), time_start = c(0, 5, 0, 5), est = c(10000, 2000, 5000, 2000) ), dist = "fixed" ) drugcost_tbl #> strategy_id time_id time_start time_stop est #> 1: 1 1 0 5 10000 #> 2: 1 2 5 Inf 2000 #> 3: 2 1 0 5 5000 #> 4: 2 2 5 Inf 2000 ## Create drug cost model drugcostmod <- create_StateVals(drugcost_tbl, n = 1, hesim_data = hesim_dat) ## Explore predictions from the drug cost model drugcostmod$sim(t = c(2, 6), type = "predict")
#>     sample strategy_id patient_id state_id time value
#>  1:      1           1          1        1    2 10000
#>  2:      1           1          1        1    6  2000
#>  3:      1           1          1        2    2 10000
#>  4:      1           1          1        2    6  2000
#>  5:      1           1          2        1    2 10000
#>  6:      1           1          2        1    6  2000
#>  7:      1           1          2        2    2 10000
#>  8:      1           1          2        2    6  2000
#>  9:      1           1          3        1    2 10000
#> 10:      1           1          3        1    6  2000
#> 11:      1           1          3        2    2 10000
#> 12:      1           1          3        2    6  2000
#> 13:      1           2          1        1    2  5000
#> 14:      1           2          1        1    6  2000
#> 15:      1           2          1        2    2  5000
#> 16:      1           2          1        2    6  2000
#> 17:      1           2          2        1    2  5000
#> 18:      1           2          2        1    6  2000
#> 19:      1           2          2        2    2  5000
#> 20:      1           2          2        2    6  2000
#> 21:      1           2          3        1    2  5000
#> 22:      1           2          3        1    6  2000
#> 23:      1           2          3        2    2  5000
#> 24:      1           2          3        2    6  2000
#>     sample strategy_id patient_id state_id time value