Learn R Programming

hesim (version 0.3.1)

tpmatrix: Transition probability matrix

Description

tpmatrix() both defines and evaluates a transition probability matrix in which elements are expressions. This function is used within define_tparams() to create a transition probability matrix used for simulation modeling.

Usage

tpmatrix(...)

Arguments

...

Named values of expressions defining elements of the matrix. The parameter values of the matrix elements should refer to parameters defined using define_rng() or define_tparams().

Value

Returns a data.table where each column is an element of the transition probability matrix with elements ordered rowwise.

Details

The matrix is filled rowwise, meaning that each row should sum to 1. It is evaluated in the environment used by eval_tparams() so that any objects available within define_tparams() can be used by tpmatrix(). The complementary probability equal to 1 minus the sum of the probabilities of all other rows can be conveniently referred to as C.

See Also

define_model(), define_tparams()

Examples

Run this code
# NOT RUN {
p <- c(.7, .6)
tpmatrix(
  C, p,
  0, 1
)
# }

Run the code above in your browser using DataLab