Skip to contents

This function builds the infinitesimal generator matrix for a continuous-time Markov chain from an unconstrained parameter vector.

Usage

generator(param, byrow = FALSE, report = TRUE)

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 with RTMB is used.

Value

infinitesimal generator matrix of dimension c(N,N)

See also

Other transition probability matrix functions: tpm(), tpm_cont(), tpm_emb(), tpm_emb_g(), tpm_g(), tpm_p()

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