Build the generator matrix of a continuous-time Markov chain
generator.Rd
This function builds the infinitesimal generator matrix for a continuous-time Markov chain from an unconstrained parameter vector.
Arguments
- param
unconstrained parameter vector of length N*(N-1) where N is the number of states of the Markov chain
- byrow
logical indicating if the transition probability matrix should be filled by row
- report
logical, indicating whether the generator matrix Q should be reported from the fitted model. Defaults to
TRUE
, but only works if when automatic differentiation withRTMB
is used.
Examples
# 2 states: 2 free off-diagonal elements
generator(rep(-1, 2))
#> [,1] [,2]
#> [1,] -0.3678794 0.3678794
#> [2,] 0.3678794 -0.3678794
# 3 states: 6 free off-diagonal elements
generator(rep(-2, 6))
#> [,1] [,2] [,3]
#> [1,] -0.2706706 0.1353353 0.1353353
#> [2,] 0.1353353 -0.2706706 0.1353353
#> [3,] 0.1353353 0.1353353 -0.2706706