Skip to contents

Transition intensities from an msmbayes model, presented as a tidy data frame

Usage

qdf(draws, new_data = NULL)

Arguments

draws

Object returned by msmbayes.

new_data

Data frame with covariate values to predict for

Value

A data frame with one row per from-state / to-state / covariate value.

Column value is in the rvar format of the posterior package, representing a sample from a posterior distribution. Use the summary function on the data frame to produce summary statistics such as the posterior median or mean (see summary.msmbayes).

See also

qmatrix returns the same information in matrix format

Examples

qdf(infsim_model)
#> # A tibble: 2 × 3
#>    from    to      value
#>   <int> <int> <rvar[1d]>
#> 1     1     2  0.67 ± NA
#> 2     2     1  3.86 ± NA
summary(qdf(infsim_model))
#>   from to     mean   median sd mad       q5      q95 rhat ess_bulk ess_tail
#> 1    1  2 0.666111 0.666111 NA   0 0.666111 0.666111   NA       NA       NA
#> 2    2  1 3.860667 3.860667 NA   0 3.860667 3.860667   NA       NA       NA
summary(qdf(infsim_model), median, ~quantile(.x, 0.025, 0.975))
#>   from to   median     2.5%
#> 1    1  2 0.666111 0.666111
#> 2    2  1 3.860667 3.860667

qdf(infsim_modelc,
    new_data = data.frame(sex=c("female","male")))
#> # A tibble: 4 × 4
#>    from    to      value sex   
#>   <int> <int> <rvar[1d]> <chr> 
#> 1     1     2  0.62 ± NA female
#> 2     1     2  0.70 ± NA male  
#> 3     2     1  3.84 ± NA female
#> 4     2     1  3.84 ± NA male