Calculate Pr(effect_dose - effect_reference_dose > EOI | data) or Pr(effect_dose > EOI | data).

pr_eoi(x, eoi, dose, reference_dose = NULL, time = NULL)

Arguments

x

output from a call to dreamer_mcmc().

eoi

a vector of the effects of interest (EOI) in the probability function.

dose

a vector of the doses for which to calculate the posterior probabilities.

reference_dose

a vector of doses for relative effects of interest.

time

the time at which to calculate the posterior quantity. Defaults to the latest timepoint. Applies to longitudinal models only.

Value

A tibble listing the doses, times, and Pr(effect_dose - effect_reference_dose > eoi) if reference_dose is specified; otherwise, Pr(effect_dose > eoi).

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:31.719
#> 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:31.783
#> total : 0.06 secs
#> mod_quad
#> start : 2024-12-19 14:43:31.784
#> 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:31.857
#> total : 0.07 secs

pr_eoi(output, dose = 3, eoi = 10)
#> # A tibble: 1 × 3
#>     eoi  dose  prob
#>   <dbl> <dbl> <dbl>
#> 1    10     3 0.262

# difference of two doses
pr_eoi(output, dose = 3, eoi = 10, reference_dose = 0)
#> # A tibble: 1 × 4
#>     eoi  dose reference_dose   prob
#>   <dbl> <dbl>          <dbl>  <dbl>
#> 1    10     3              0 0.0492

# single model
pr_eoi(output$mod_linear, dose = 3, eoi = 10)
#> # A tibble: 1 × 3
#>     eoi  dose  prob
#>   <dbl> <dbl> <dbl>
#> 1    10     3 0.257