Summarize parameter inference and convergence diagnostics.

# S3 method for class 'dreamer_bma'
summary(object, ...)

Arguments

object

a dreamer MCMC object.

...

additional arguments (which are ignored).

Value

Returns a named list with elements model_weights and summary containing the prior and posterior weights for each model and inference on parameters for each model as well as MCMC diagnostics.

Examples

set.seed(888)
data <- dreamer_data_linear(
  n_cohorts = c(20, 20, 20),
  dose = c(0, 3, 10),
  b1 = 1,
  b2 = 3,
  sigma = 5
)

# Bayesian model averaging
output <- dreamer_mcmc(
 data = data,
 n_adapt = 1e3,
 n_burn = 1e3,
 n_iter = 1e4,
 n_chains = 2,
 silent = FALSE,
 mod_linear = model_linear(
   mu_b1 = 0,
   sigma_b1 = 1,
   mu_b2 = 0,
   sigma_b2 = 1,
   shape = 1,
   rate = .001,
   w_prior = 1 / 2
 ),
 mod_quad = model_quad(
   mu_b1 = 0,
   sigma_b1 = 1,
   mu_b2 = 0,
   sigma_b2 = 1,
   mu_b3 = 0,
   sigma_b3 = 1,
   shape = 1,
   rate = .001,
   w_prior = 1 / 2
 )
)
#> mod_linear
#> start : 2024-12-19 14:43:33.776
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 6
#>    Unobserved stochastic nodes: 3
#>    Total graph size: 50
#> 
#> Initializing model
#> 
#> finish: 2024-12-19 14:43:33.841
#> total : 0.06 secs
#> mod_quad
#> start : 2024-12-19 14:43:33.842
#> Compiling model graph
#>    Resolving undeclared variables
#>    Allocating nodes
#> Graph information:
#>    Observed stochastic nodes: 6
#>    Unobserved stochastic nodes: 4
#>    Total graph size: 59
#> 
#> Initializing model
#> 
#> finish: 2024-12-19 14:43:33.916
#> total : 0.07 secs

# all models (also show model weights)
summary(output)
#> $model_weights
#> # A tibble: 2 × 3
#>   model      posterior_weight prior_weight
#>   <chr>      <chr>            <chr>       
#> 1 mod_linear 72.1%            50.0%       
#> 2 mod_quad   27.9%            50.0%       
#> 
#> $summary
#> # A tibble: 7 × 14
#>   model      param   mean     sd       se    se_ts  `2.5%`   `25%`  `50%`  `75%`
#>   <chr>      <chr>  <dbl>  <dbl>    <dbl>    <dbl>   <dbl>   <dbl>  <dbl>  <dbl>
#> 1 mod_linear b1    0.562  0.694  0.00490  0.00482  -0.813   0.0950 0.568  1.03  
#> 2 mod_linear b2    3.02   0.139  0.000979 0.000979  2.75    2.93   3.02   3.12  
#> 3 mod_linear sigma 5.23   0.489  0.00346  0.00350   4.37    4.88   5.18   5.53  
#> 4 mod_quad   b1    0.612  0.730  0.00516  0.00514  -0.808   0.121  0.602  1.10  
#> 5 mod_quad   b2    2.87   0.564  0.00398  0.00430   1.74    2.50   2.88   3.26  
#> 6 mod_quad   b3    0.0156 0.0556 0.000393 0.000425 -0.0905 -0.0223 0.0147 0.0529
#> 7 mod_quad   sigma 5.29   0.509  0.00360  0.00398   4.41    4.93   5.25   5.61  
#> # ℹ 4 more variables: `97.5%` <dbl>, gelman_point <dbl>, gelman_upper <dbl>,
#> #   effective_size <dbl>
#> 

# single model
summary(output$mod_linear)
#> # A tibble: 3 × 13
#>   param  mean    sd       se    se_ts `2.5%`  `25%` `50%` `75%` `97.5%`
#>   <chr> <dbl> <dbl>    <dbl>    <dbl>  <dbl>  <dbl> <dbl> <dbl>   <dbl>
#> 1 b1    0.562 0.694 0.00490  0.00482  -0.813 0.0950 0.568  1.03    1.92
#> 2 b2    3.02  0.139 0.000979 0.000979  2.75  2.93   3.02   3.12    3.29
#> 3 sigma 5.23  0.489 0.00346  0.00350   4.37  4.88   5.18   5.53    6.30
#> # ℹ 3 more variables: gelman_point <dbl>, gelman_upper <dbl>,
#> #   effective_size <dbl>