Calculates the posterior probability that each specified doses are the minimum effective dose in the set; i.e. the smallest dose that has a clinically significant difference (CSD).

pr_med(
  x,
  doses = attr(x, "doses"),
  csd = NULL,
  reference_dose = NULL,
  greater = TRUE,
  time = NULL
)

Arguments

x

output from a call to dreamer_mcmc().

doses

the doses for which pr(MED) is to be calculated.

csd

the treatment effect that is clinically relevant.

reference_dose

a single dose that is used as the reference when defining the MED relative to a dose (rather than in absolute terms). When reference_dose is specified, this function calculates the posterior probability that each dose is the smallest dose such that (effect_dose - effect_reference_dose > CSD).

greater

if TRUE, higher responses indicate better efficacy. If FALSE, lower responses indicate better efficacy.`

time

the time (scalar) at which the Pr(MED) should be calculated. Applies only to longitudinal models.

Value

A tibble listing each dose and the posterior probability that each dose is the minimum efficacious dose.

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 = 1e3,
 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-04-01 17:24:46.402
#> 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-04-01 17:24:46.420
#> total : 0.02 secs
#> mod_quad
#> start : 2024-04-01 17:24:46.420
#> 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-04-01 17:24:46.439
#> total : 0.02 secs

pr_med(output, csd = 10)
#> # A tibble: 3 × 2
#>    dose  prob
#>   <dbl> <dbl>
#> 1     0 0    
#> 2     3 0.258
#> 3    10 0.742

# difference of two doses
pr_med(output, csd = 3, reference_dose = 0)
#> # A tibble: 3 × 3
#>    dose reference_dose  prob
#>   <dbl>          <dbl> <dbl>
#> 1     0              0     0
#> 2     3              0     1
#> 3    10              0     0

# single model
pr_med(output$mod_quad, csd = 10)
#> # A tibble: 3 × 2
#>    dose  prob
#>   <dbl> <dbl>
#> 1     0 0    
#> 2     3 0.285
#> 3    10 0.715