qmatrix.matrix | R Documentation |
Creates transition intensity matrices where elements represent the instantaneous risk of moving between health states.
## 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, ...)
x |
A two-dimensional tabular object containing elements of the transition intensity matrix. A column represents a transition from state r to state s. Each row represents elements of a different transition intensity matrix. See "Details" for more information. |
trans_mat |
Just as in |
... |
Further arguments passed to or from other methods. Currently unused. |
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.
An array of transition intensity matrices with the third dimension
equal to the number of rows in x
.
qmatrix.msm()
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.