Posterior Distribution of Minimum X% Effective Dose

post_medx(
  x,
  ed,
  probs,
  time,
  lower,
  upper,
  greater,
  small_bound,
  return_samples,
  ...
)

# S3 method for dreamer_bma
post_medx(
  x,
  ed,
  probs = c(0.025, 0.975),
  time = NULL,
  lower = min(x$doses),
  upper = max(x$doses),
  greater = TRUE,
  small_bound = 0,
  return_samples = FALSE,
  ...
)

# S3 method for dreamer_mcmc
post_medx(
  x,
  ed,
  probs = c(0.025, 0.975),
  time = NULL,
  lower = min(attr(x, "doses")),
  upper = max(attr(x, "doses")),
  greater = TRUE,
  small_bound = 0,
  return_samples = FALSE,
  index = 1:(nrow(x[[1]]) * length(x)),
  ...
)

Arguments

x

output from dreamer_mcmc().

ed

a number between 0 and 100 indicating the ed% dose that is being sought.

probs

a vector of quantiles to calculate on the posterior.

time

the slice of time for which to calculate the posterior EDX dose. Applies to longitudinal models only.

lower

the lower bound of the doses for calculating EDX.

upper

the upper bound of the doses for calculating EDX.

greater

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

small_bound

the minimum (greater = TRUE) or maximum (greater = FALSE) bound of the response.

return_samples

logical indicating if the posterior samples should be returned.

...

additional arguments for specific methods.

index

a vector indicating which MCMC samples to use in the calculation. If NULL (default), all MCMC samples are used.

Value

Posterior quantities and samples (if applicable), generally in the form of a list. The pr_edx_exists column gives the posterior probability that an EDX% effect exists.

Details

The minimum X% effective dose is the dose that has X% of the largest effect for doses between lower and upper. When greater is TRUE, larger positive responses are considered more effective and vice versa. The X% response is calculated as small_bound + ed / 100 * (max_effect - small_bound) where "max_effect" is the maximum response for doses between lower and upper. The X% effective dose is the smallest dose which has X% response within the dose range. It is possible that for some MCMC samples, an X% effective dose may not exist, so probabilities are not guaranteed to sum to one.

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:43.340
#> 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:43.362
#> total : 0.02 secs
#> mod_quad
#> start : 2024-04-01 17:24:43.362
#> 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:43.391
#> total : 0.03 secs

post_medx(output, ed = c(50, 90))
#> $stats
#>   ed pr_edx_exists     mean     2.5%    97.5%
#> 1 50             1 4.934277 4.449656 5.568752
#> 2 90             1 8.986711 8.785120 9.183197
#> 

# from a single model
post_medx(output$mod_linear, ed = c(50, 90))
#> $stats
#>   ed pr_edx_exists     mean     2.5%    97.5%
#> 1 50             1 4.900778 4.660334 5.120568
#> 2 90             1 8.980156 8.932067 9.024114
#>