summary.tpmatrix {hesim} | R Documentation |
Summarize transition probability matrix
Description
Summarize a tpmatrix
object storing transition probability matrices.
Summary statistics are computed for each possible transition.
Usage
## S3 method for class 'tpmatrix'
summary(object, id = NULL, probs = NULL, unflatten = FALSE, ...)
Arguments
object |
A |
id |
A |
probs |
A numeric vector of probabilities with values in |
unflatten |
If |
... |
Additional arguments affecting the summary. Currently unused. |
Value
If unflatten = "FALSE"
(the default), then a data.table
is returned with columns for (i) the health state that is being transitioned
from (from
), (ii) the health state that is being transitioned to (to
)
(iii) the mean of each parameter across parameter samples (mean
),
(iv) the standard deviation of the parameter samples (sd
), and
(v) quantiles of the parameter samples corresponding to the probs
argument.
If, on the other hand, unflatten = "TRUE"
, then the parameters are unflattened
to form transition probability matrices; that is, the mean
, sd
, and
quantile columns are (lists of) matrices.
In both cases, if id
is not NULL
, then the ID variables are also
returned as columns.
Examples
library("data.table")
hesim_dat <- hesim_data(strategies = data.table(strategy_id = 1:2),
patients = data.table(patient_id = 1:3))
input_data <- expand(hesim_dat, by = c("strategies", "patients"))
# Summarize across all rows in "input_data"
p_12 <- ifelse(input_data$strategy_id == 1, .8, .6)
p <- tpmatrix(
C, p_12,
0, 1
)
## Summary where each column is a vector
summary(p)
summary(p, probs = c(.025, .975))
## Summary where each column is a matrix
ps <- summary(p, probs = .5, unflatten = TRUE)
ps
ps$mean
# Summarize by ID variables
tpmat_id <- tpmatrix_id(input_data, n_samples = 2)
p_12 <- ifelse(tpmat_id$strategy_id == 1, .8, .6)
p <- tpmatrix(
C, p_12,
0, 1
)
## Summary where each column is a vector
summary(p, id = tpmat_id)
## Summary where each column is a matrix
ps <- summary(p, id = tpmat_id, unflatten = TRUE)
ps
ps$mean