# Create transition model

Source: `R/transmod.R`
`create_transmod.Rd`

Create a model for simulating health state transitions with a continuous time state transition model (CTSTM).

    create_transmod(params, data)

## Arguments

params | A "params_surv" object returned from `create_transmod_params`.
data | A data table of class "expanded_hesim_data" returned from `create_transmod_data`.

## Value

An object of class "IndivCtstmTrans" from the hesim package.

## Examples

    # Treatment sequences
    txseq1 <- txseq(first = "erlotinib",
                    second = c("osimertinib", "PBDC"),
                    second_plus = c("PBDC + bevacizumab", "PBDC + bevacizumab"))
    txseq2 <- txseq(first = "gefitinib",
                    second = c("osimertinib", "PBDC"),
                    second_plus = c("PBDC + bevacizumab", "PBDC + bevacizumab"))
    txseqs <- txseq_list(seq1 = txseq1, seq2 = txseq2)

    # Patient population
    pats <- create_patients(n = 2)

    # Model structure
    struct <- model_structure(txseqs, dist = "weibull")
    tmat <- create_trans_mat(struct)

    # Data for state transition model
    transmod_data <- create_transmod_data(struct, tmat, pats)
    head(transmod_data)#>    strategy_id patient_id transition_id female      age mutation tx_abb tx_hist
    #> 1:           1          1             1      0 54.03749        1    erl    <NA>
    #> 2:           1          1             2      0 54.03749        1    erl    <NA>
    #> 3:           1          1             3      0 54.03749        1    osi     erl
    #> 4:           1          1             4      0 54.03749        1    osi     erl
    #> 5:           1          1             5      0 54.03749        1    osi     erl
    #> 6:           1          2             1      0 73.37210        1    erl    <NA>
    #>    gef_s1p1_a0 gef_s1d_a0 d_erl_s1p1_a0 d_erl_s1d_a0 osi_s2p2_a0 osi_s2d_a0
    #> 1:           1          0             1            0           0          0
    #> 2:           0          1             0            1           0          0
    #> 3:           0          0             0            0           1          0
    #> 4:           0          0             0            0           0          1
    #> 5:           0          0             0            0           0          0
    #> 6:           1          0             1            0           0          0
    #>    osi_p2d_a0 pbdc_s2p2_a0 pbdc_s2d_a0 pbdc_p2d_a0 gef_s1p1_a1 gef_s1d_a1
    #> 1:          0            0           0           0           1          0
    #> 2:          0            0           0           0           0          1
    #> 3:          0            0           0           0           0          0
    #> 4:          0            0           0           0           0          0
    #> 5:          1            0           0           0           0          0
    #> 6:          0            0           0           0           1          0
    #>    d_erl_s1p1_a1 d_erl_s1d_a1 osi_s2p2_a1 osi_s2d_a1 osi_p2d_a1 pbdc_s2p2_a1
    #> 1:             1            0           0          0          0            0
    #> 2:             0            1           0          0          0            0
    #> 3:             0            0           1          0          0            0
    #> 4:             0            0           0          1          0            0
    #> 5:             0            0           0          0          1            0
    #> 6:             1            0           0          0          0            0
    #>    pbdc_s2d_a1 pbdc_p2d_a1
    #> 1:           0           0
    #> 2:           0           0
    #> 3:           0           0
    #> 4:           0           0
    #> 5:           0           0
    #> 6:           0           0
    # Parameters for state transition model
    transmod_params <- create_transmod_params(n = 2, transmod_data)
    print(transmod_params)#> $coefs
    #> $coefs$a0
    #>      d_erl_s1p1_a0 d_erl_s1d_a0 gef_s1p1_a0 gef_s1d_a0 osi_s2p2_a0 osi_s2d_a0
    #> [1,]    -0.1695568            0   -3.850149  -9.513523   -2.657322 -12.071691
    #> [2,]    -0.3158846            0   -3.873477  -6.987298   -3.223167  -6.953787
    #>      osi_p2d_a0 pbdc_s2p2_a0 pbdc_s2d_a0 pbdc_p2d_a0
    #> [1,]  -4.661446    -2.357226   -9.544715   -2.363616
    #> [2,]  -4.404432    -2.387992  -10.769347   -2.011830
    #>
    #> $coefs$a1
    #>      d_erl_s1p1_a1 d_erl_s1d_a1 gef_s1p1_a1 gef_s1d_a1 osi_s2p2_a1 osi_s2d_a1
    #> [1,]    -0.2123671            0   0.7227243          0   0.1572655          0
    #> [2,]    -0.3730880            0   0.6407160          0   0.4505773          0
    #>      osi_p2d_a1 pbdc_s2p2_a1 pbdc_s2d_a1 pbdc_p2d_a1
    #> [1,]  0.4244667    0.4645846           0  -0.1588428
    #> [2,]  0.3126212    0.3641004           0  -0.3788891
    #>
    #>
    #> $dist
    #> [1] "weibullNMA"
    #>
    #> $n_samples
    #> [1] 2
    #>
    #> attr(,"class")
    #> [1] "params_surv"
    # State transition model
    transmod <- create_transmod(transmod_params, transmod_data)