post_medx: Posterior Distribution of Minimum X% Effective Dose

View source: R/post_medx.R

post_medxR Documentation

Posterior Distribution of Minimum X% Effective Dose

Description

Posterior Distribution of Minimum X% Effective Dose

Usage

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

## S3 method for class '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 class '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.

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.

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.

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
 )
)

post_medx(output, ed = c(50, 90))

# from a single model
post_medx(output$mod_linear, ed = c(50, 90))

dreamer documentation built on Sept. 1, 2022, 5:05 p.m.