hb_ess {historicalborrow} | R Documentation |
Effective sample size (ESS)
Description
Quantify borrowing with effective sample size (ESS) as cited and explained in the methods vignette at https://wlandau.github.io/historicalborrow/articles/methods.html.
Usage
hb_ess(
mcmc_pool,
mcmc_hierarchical,
data,
response = "response",
study = "study",
study_reference = max(data[[study]]),
group = "group",
group_reference = min(data[[group]]),
patient = "patient"
)
Arguments
mcmc_pool |
A fitted model from |
mcmc_hierarchical |
A fitted model from |
data |
A tidy data frame or |
response |
Character of length 1,
name of the column in |
study |
Character of length 1,
name of the column in |
study_reference |
Atomic of length 1,
element of the |
group |
Character of length 1,
name of the column in |
group_reference |
Atomic of length 1,
element of the |
patient |
Character of length 1,
name of the column in |
Value
A data frame with one row and the following columns:
-
v0
: posterior predictive variance of the control group mean of a hypothetical new study given the pooled model. Calculated as the mean over MCMC samples of1 / sum(sigma_i ^ 2)
, where eachsigma_i
is the residual standard deviation of studyi
estimated from the pooled model. -
v_tau
: posterior predictive variance of a hypothetical new control group mean under the hierarchical model. Calculated by averaging over predictive draws, where each predictive draw is fromrnorm(n = 1, mean = mu_, sd = tau_)
andmu_
andtau_
are themu
andtau
components of an MCMC sample. -
n
: number of non-missing historical control patients. -
weight
: strength of borrowing as a ratio of variances:v0 / v_tau
. -
ess
: strength of borrowing as an effective sample size:n v0 / v_tau
, wheren
is the number of non-missing historical control patients.
See Also
Other summary:
hb_summary()
Examples
data <- hb_sim_independent(n_continuous = 2)$data
data$group <- sprintf("group%s", data$group)
data$study <- sprintf("study%s", data$study)
pool <- hb_mcmc_pool(
data,
n_chains = 1,
n_adapt = 100,
n_warmup = 50,
n_iterations = 50
)
hierarchical <- hb_mcmc_hierarchical(
data,
n_chains = 1,
n_adapt = 100,
n_warmup = 50,
n_iterations = 50
)
hb_ess(
mcmc_pool = pool,
mcmc_hierarchical = hierarchical,
data = data
)