qmatrix.matrix {hesim} | R Documentation |
Transition intensity matrix from tabular object
Description
Creates transition intensity matrices where elements represent the instantaneous risk of moving between health states.
Usage
## S3 method for class 'matrix'
qmatrix(x, trans_mat, ...)
## S3 method for class 'data.table'
qmatrix(x, trans_mat, ...)
## S3 method for class 'data.frame'
qmatrix(x, trans_mat, ...)
Arguments
x |
A two-dimensional tabular object containing
elements of the transition intensity matrix. A column represents a transition
from state |
trans_mat |
Just as in |
... |
Further arguments passed to or from other methods. Currently unused. |
Details
The object x
must only contain non-zero and non-diagonal elements
of a transition intensity matrix. The diagonal elements are automatically computed
as the negative sum of the other rows.
Value
An array of transition intensity matrices with the third dimension
equal to the number of rows in x
.
See Also
Examples
# 3 state irreversible model
tmat <- rbind(c(NA, 1, 2),
c(NA, NA, 3),
c(NA, NA, NA))
q12 <- c(.8, .7)
q13 <- c(.2, .3)
q23 <- c(1.1, 1.2)
q <- data.frame(q12, q13, q23)
qmat <- qmatrix(q, trans_mat = tmat)
print(qmat)
# Matrix exponential of each matrix in array
expmat(qmat)