Summarize a `tpmatrix`

object storing transition probability matrices.
Summary statistics are computed for each possible transition.

# S3 method for tpmatrix summary(object, id = NULL, probs = NULL, unflatten = FALSE, ...)

object | A |
---|---|

id | A |

probs | A numeric vector of probabilities with values in |

unflatten | If |

... | Additional arguments affecting the summary. Currently unused. |

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.

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)#> from to mean sd #> 1: s1 s1 0.3 0.1095445 #> 2: s1 s2 0.7 0.1095445 #> 3: s2 s1 0.0 0.0000000 #> 4: s2 s2 1.0 0.0000000#> from to mean sd 2.5% 97.5% #> 1: s1 s1 0.3 0.1095445 0.2 0.4 #> 2: s1 s2 0.7 0.1095445 0.6 0.8 #> 3: s2 s1 0.0 0.0000000 0.0 0.0 #> 4: s2 s2 1.0 0.0000000 1.0 1.0#> mean sd 50% #> 1: 0.3,0.0,0.7,1.0 0.1095445,0.0000000,0.1095445,0.0000000 0.3,0.0,0.7,1.0ps$mean#> [[1]] #> s1 s2 #> s1 0.3 0.7 #> s2 0.0 1.0 #># 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)#> strategy_id patient_id from to mean sd #> 1: 1 1 s1 s1 0.2 0 #> 2: 1 1 s1 s2 0.8 0 #> 3: 1 1 s2 s1 0.0 0 #> 4: 1 1 s2 s2 1.0 0 #> 5: 1 2 s1 s1 0.2 0 #> 6: 1 2 s1 s2 0.8 0 #> 7: 1 2 s2 s1 0.0 0 #> 8: 1 2 s2 s2 1.0 0 #> 9: 1 3 s1 s1 0.2 0 #> 10: 1 3 s1 s2 0.8 0 #> 11: 1 3 s2 s1 0.0 0 #> 12: 1 3 s2 s2 1.0 0 #> 13: 2 1 s1 s1 0.4 0 #> 14: 2 1 s1 s2 0.6 0 #> 15: 2 1 s2 s1 0.0 0 #> 16: 2 1 s2 s2 1.0 0 #> 17: 2 2 s1 s1 0.4 0 #> 18: 2 2 s1 s2 0.6 0 #> 19: 2 2 s2 s1 0.0 0 #> 20: 2 2 s2 s2 1.0 0 #> 21: 2 3 s1 s1 0.4 0 #> 22: 2 3 s1 s2 0.6 0 #> 23: 2 3 s2 s1 0.0 0 #> 24: 2 3 s2 s2 1.0 0 #> strategy_id patient_id from to mean sd#> strategy_id patient_id mean sd #> 1: 1 1 0.2,0.0,0.8,1.0 0,0,0,0 #> 2: 1 2 0.2,0.0,0.8,1.0 0,0,0,0 #> 3: 1 3 0.2,0.0,0.8,1.0 0,0,0,0 #> 4: 2 1 0.4,0.0,0.6,1.0 0,0,0,0 #> 5: 2 2 0.4,0.0,0.6,1.0 0,0,0,0 #> 6: 2 3 0.4,0.0,0.6,1.0 0,0,0,0ps$mean#> [[1]] #> s1 s2 #> s1 0.2 0.8 #> s2 0.0 1.0 #> #> [[2]] #> s1 s2 #> s1 0.2 0.8 #> s2 0.0 1.0 #> #> [[3]] #> s1 s2 #> s1 0.2 0.8 #> s2 0.0 1.0 #> #> [[4]] #> s1 s2 #> s1 0.4 0.6 #> s2 0.0 1.0 #> #> [[5]] #> s1 s2 #> s1 0.4 0.6 #> s2 0.0 1.0 #> #> [[6]] #> s1 s2 #> s1 0.4 0.6 #> s2 0.0 1.0 #>