Posterior Distribution of Minimum X% Effective Dose
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)),
...
)
output from dreamer_mcmc()
.
a number between 0 and 100 indicating the ed% dose that is being sought.
a vector of quantiles to calculate on the posterior.
the slice of time for which to calculate the posterior EDX dose. Applies to longitudinal models only.
the lower bound of the doses for calculating EDX.
the upper bound of the doses for calculating EDX.
if TRUE
, higher values indicate better efficacy. If
FALSE
, lower responses indicate better efficacy.
the minimum (greater = TRUE
) or maximum
(greater = FALSE
) bound of the response.
logical indicating if the posterior samples should be returned.
additional arguments for specific methods.
a vector indicating which MCMC samples to use in the
calculation. If NULL
(default), all MCMC samples are used.
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.
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.
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-12-19 14:43:29.508
#> 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:29.526
#> total : 0.02 secs
#> mod_quad
#> start : 2024-12-19 14:43:29.527
#> 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:29.546
#> total : 0.02 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
#>