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).

apply_rr(x, rr, index, complement = NULL)

Arguments

x A 3-dimensional array where each slice is a square transition probability matrix. 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 x. The indices of the transition probability matrices that rr is applied to. Should either be a matrix where the first column denotes a transition probability matrix row and the second column denotes a transition probability matrix column or a list where each element is a vector of length 2 with the first element denoting a transition probability matrix row and the second column denoting a transition probability matrix column. Denotes indices of transition probability matrices that are "complements" (i.e., computed as $$1$$ less the sum of all other elements in that row). Should be in the same format as index. There can be at most one complementary column in each row of a transition probability matrix. If NULL, then the diagonals are assumed to be the complements.

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.

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.

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)))
#> , , 1 #> #> [,1] [,2] [,3] #> [1,] 0.2599459 0.6423888 0.09766537 #> [2,] 0.0000000 0.9000000 0.10000000 #> [3,] 0.0000000 0.0000000 1.00000000 #> #> , , 2 #> #> [,1] [,2] [,3] #> [1,] 0.4887967 0.4113606 0.09984273 #> [2,] 0.0000000 0.8000000 0.20000000 #> [3,] 0.0000000 0.0000000 1.00000000 #>
# 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)))
#> , , 1 #> #> [,1] [,2] [,3] #> [1,] 0.3135021 0.5954554 0.09104254 #> [2,] 0.0000000 0.9000000 0.10000000 #> [3,] 0.0000000 0.0000000 1.00000000 #> #> , , 2 #> #> [,1] [,2] [,3] #> [1,] 0.4652217 0.4354188 0.09935959 #> [2,] 0.0000000 0.8000000 0.20000000 #> [3,] 0.0000000 0.0000000 1.00000000 #> #> , , 3 #> #> [,1] [,2] [,3] #> [1,] 0.2926727 0.6117967 0.09553057 #> [2,] 0.0000000 0.9000000 0.10000000 #> [3,] 0.0000000 0.0000000 1.00000000 #> #> , , 4 #> #> [,1] [,2] [,3] #> [1,] 0.4241173 0.4787659 0.09711682 #> [2,] 0.0000000 0.8000000 0.20000000 #> [3,] 0.0000000 0.0000000 1.00000000 #>