apply_rr {hesim} | R Documentation |
Apply relative risks to transition probability matrices
Description
Elements of transition probability matrices are multiplied by relative risks and the transition probability matrices are adjusted so that rows sum to 1. Operations are vectorized and each relative risk is multiplied by every transition matrix (stored in 3-dimensional arrays).
Usage
apply_rr(x, rr, index, complement = NULL)
Arguments
x |
A 3-dimensional array where each slice is a square transition probability matrix. |
rr |
A 2-dimensional tabular object such as a matrix or data frame where each
column is a vector of relative risks to apply to each transition matrix in |
index |
The indices of the transition probability matrices that |
complement |
Denotes indices of transition probability matrices that are
"complements" (i.e., computed as |
Details
This function is useful for applying relative treatment effects measured
using relative risks to an existing transition probability matrix. For example,
a transition probability matrix for the reference treatment strategy may exist or
have been estimated from the data. Relative risks estimated from a meta-analysis
or network meta-analysis can then be applied to the reference transition probability
matrix. If the number of rows in rr
exceeds x
, then the arrays in x
are
recycled to the number of rows in rr
, which facilitates the application of
relative risks from multiple treatment strategies to a reference treatment.
Value
A 3-dimensional array where each slice contains matrices of the same
dimension as each matrix in x
and the number of slices is equal to the number
of rows in rr
.
Examples
p_12 <- c(.7, .5)
p_23 <- c(.1, .2)
x <- as_array3(tpmatrix(
C, p_12, .1,
0, C, p_23,
0, 0, 1
))
# There are the same number of relative risk rows and transition probability matrices
rr_12 <- runif(2, .8, 1)
rr_13 <- runif(2, .9, 1)
rr <- cbind(rr_12, rr_13)
apply_rr(x, rr,
index = list(c(1, 2), c(1, 3)),
complement = list(c(1, 1), c(2, 2)))
# There are more relative risk rows than transition probability matrices
rr_12 <- runif(4, .8, 1)
rr_13 <- runif(4, .9, 1)
rr <- cbind(rr_12, rr_13)
apply_rr(x, rr,
index = list(c(1, 2), c(1, 3)),
complement = list(c(1, 1), c(2, 2)))