Creates ID variables for each row returned by tpmatrix(). This function is most conveniently used along with tpmatrix() to construct a tparams_transprobs() object.

tpmatrix_id(object, n_samples)

Arguments

object

An object of class expanded_hesim_data returned by expand.hesim_data(). This dataset must be expanded by treatment strategies, patients, and optionally time intervals.

n_samples

The number of parameters samples used for the probabilistic sensitivity analysis (PSA).

Value

Returns a tpmatrix_id object that inherits from data.table with the same columns in object repeated n_samples times. That is, to facilitate creation of a tparams_transprobs() object, there is one row for each parameter sample, treatment strategy, patient, and optionally time interval.

Examples

strategies <- data.frame(strategy_id = c(1, 2))
patients <- data.frame(patient_id = seq(1, 3), age = c(65, 50, 75),
                        gender = c("Female", "Female", "Male"))
hesim_dat <- hesim_data(strategies = strategies,
                        patients = patients)
input_data <- expand(hesim_dat, by = c("strategies", "patients"))    
tpmatrix_id(input_data, n_samples = 2)                   
#>     sample strategy_id patient_id
#>  1:      1           1          1
#>  2:      1           1          2
#>  3:      1           1          3
#>  4:      1           2          1
#>  5:      1           2          2
#>  6:      1           2          3
#>  7:      2           1          1
#>  8:      2           1          2
#>  9:      2           1          3
#> 10:      2           2          1
#> 11:      2           2          2
#> 12:      2           2          3