Draw transition intensity matrices for a probabilistic sensitivity analysis
from a fitted msm
object.
A msm::msm
object.
A data frame to look for variables with which to predict. A
separate transition intensity matrix is predicted based on each row in
newdata
. Can be NULL
if no covariates are included in the fitted msm
object.
Method used to draw transition intensity matrices. If "none
",
then point estimates are used. If "normal"
, then samples are drawn from the
multivariate normal distribution of the regression coefficients.
Number of random observations of the parameters to draw.
Further arguments passed to or from other methods. Currently unused.
An array of transition intensity matrices with the third dimension
equal to the number of rows in newdata
.
library("msm")
set.seed(101)
qinit <- rbind(
c(0, 0.28163, 0.01239),
c(0, 0, 0.10204),
c(0, 0, 0)
)
fit <- msm(state_id ~ time, subject = patient_id,
data = onc3p[patient_id %in% sample(patient_id, 100)],
covariates = list("1-2" =~ age + strategy_name),
qmatrix = qinit)
qmatrix(fit, newdata = data.frame(age = 55, strategy_name = "New 1"),
uncertainty = "none")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] -0.4381051 0.43802597 7.908247e-05
#> [2,] 0.0000000 -0.08275169 8.275169e-02
#> [3,] 0.0000000 0.00000000 0.000000e+00
#>
qmatrix(fit, newdata = data.frame(age = 55, strategy_name = "New 1"),
uncertainty = "normal", n = 3)
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] -0.4638766 0.46374092 0.0001356372
#> [2,] 0.0000000 -0.09029487 0.0902948725
#> [3,] 0.0000000 0.00000000 0.0000000000
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] -0.5366117 0.53661167 1.010129e-08
#> [2,] 0.0000000 -0.08288779 8.288779e-02
#> [3,] 0.0000000 0.00000000 0.000000e+00
#>
#> , , 3
#>
#> [,1] [,2] [,3]
#> [1,] -0.3732095 0.37319992 9.546918e-06
#> [2,] 0.0000000 -0.07399928 7.399928e-02
#> [3,] 0.0000000 0.00000000 0.000000e+00
#>