Skip to contents

Help functions to get insight into the structure of a transition matrix.

Arguments

trans

Transition matrix, for instance produced by transMat), trans.comprisk, or trans.illdeath

Value

See details.

Details

Function to.trans2 simply lists the transitions in trans in a data frame; function trans2Q converts trans to a Q matrix, the (j,k)th element of which contains the (shortest) number of transitions needed to travel from the jth to the kth state; function absorbing returns a vector (named if trans contains row or columnc names) with the state numbers that are absorbing; function is.circular returns (a Boolean) whether the transition matrix specified in trans is circular or not.

Author

Hein Putter <H.Putter@lumc.nl>

Examples


# Irreversible illness-death model
tmat <- trans.illdeath(c("Healthy", "Illness", "Death"))
tmat
#>          to
#> from      Healthy Illness Death
#>   Healthy      NA       1     2
#>   Illness      NA      NA     3
#>   Death        NA      NA    NA
to.trans2(tmat)
#>   transno from to fromname  toname          transname
#> 1       1    1  2  Healthy Illness Healthy -> Illness
#> 2       2    1  3  Healthy   Death   Healthy -> Death
#> 3       3    2  3  Illness   Death   Illness -> Death
trans2Q(tmat)
#>          to
#> from      Healthy Illness Death
#>   Healthy       0       1     1
#>   Illness       0       0     1
#>   Death         0       0     0
absorbing(tmat)
#> Death 
#>     3 
is.circular(tmat)
#> [1] FALSE
# Reversible illness-death model
tmat <- transMat(x = list( c(2, 3), c(1, 3), c() ),
                 names = c("Healthy", "Illness", "Death"))
tmat
#>          to
#> from      Healthy Illness Death
#>   Healthy      NA       1     2
#>   Illness       3      NA     4
#>   Death        NA      NA    NA
to.trans2(tmat)
#>   transno from to fromname  toname          transname
#> 1       1    1  2  Healthy Illness Healthy -> Illness
#> 2       2    1  3  Healthy   Death   Healthy -> Death
#> 3       3    2  1  Illness Healthy Illness -> Healthy
#> 4       4    2  3  Illness   Death   Illness -> Death
trans2Q(tmat)
#>          to
#> from      Healthy Illness Death
#>   Healthy       2       1     1
#>   Illness       1       2     1
#>   Death         0       0     0
absorbing(tmat)
#> Death 
#>     3 
is.circular(tmat)
#> [1] TRUE