hbl_ess {historicalborrowlong} | 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/historicalborrowlong/articles/methods.html.
Usage
hbl_ess(
mcmc_pool,
mcmc_hierarchical,
data,
response = "response",
study = "study",
study_reference = max(data[[study]]),
group = "group",
group_reference = min(data[[group]]),
patient = "patient",
rep = "rep",
rep_reference = min(data[[rep]])
)
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 |
rep |
Character of length 1,
name of the column in |
rep_reference |
Atomic of length 1,
element of the |
Value
A data frame with one row per discrete time point ("rep") 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 a prior effective sample size:n v0 / v_tau
, wheren
is the number of non-missing historical control patients.
See Also
Other summary:
hbl_summary()
Examples
set.seed(0)
data <- hbl_sim_independent(n_continuous = 2)$data
data$group <- sprintf("group%s", data$group)
data$study <- sprintf("study%s", data$study)
data$rep <- sprintf("rep%s", data$rep)
tmp <- utils::capture.output(
suppressWarnings(
pool <- hbl_mcmc_pool(
data,
chains = 1,
warmup = 10,
iter = 20,
seed = 0
)
)
)
tmp <- utils::capture.output(
suppressWarnings(
hierarchical <- hbl_mcmc_hierarchical(
data,
chains = 1,
warmup = 10,
iter = 20,
seed = 0
)
)
)
hbl_ess(
mcmc_pool = pool,
mcmc_hierarchical = hierarchical,
data = data
)