hb_mcmc_mixture_hyperparameters {historicalborrow} | R Documentation |
Mixture model MCMC hyperparameters
Description
Run a simple model separately on each historical study
control group and compute hyperparameters for hb_mcmc_mixture()
.
Usage
hb_mcmc_mixture_hyperparameters(
data,
response = "response",
study = "study",
study_reference = max(data[[study]]),
group = "group",
group_reference = min(data[[group]]),
patient = "patient",
m_mu = 0,
s_mu = 30,
s_sigma = 30,
m_omega_current = 0,
s_omega_current = 30,
n_chains = 4,
n_adapt = 2000,
n_warmup = 4000,
n_iterations = 20000,
quiet = TRUE
)
Arguments
data |
Tidy data frame with one row per patient,
indicator columns for the response variable,
study, group, and patient,
and covariates. All columns must be atomic vectors
(e.g. not lists). The data for the mixture and simple models
should have just one study,
and the others should have
data from more than one study. The simple model can be used
to get the historical data components of |
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 |
m_mu |
Numeric of length 1, prior mean of the mean |
s_mu |
Numeric of length 1, prior standard deviation of the
mean |
s_sigma |
Numeric of length 1, uniform prior upper bound
of the residual standard deviation |
m_omega_current |
Numeric with length 1,
|
s_omega_current |
Numeric with length 1,
|
n_chains |
Number of MCMC chains to run. |
n_adapt |
Number of adaptation iterations to run. |
n_warmup |
Number of warmup iterations per chain to run. |
n_iterations |
Number of saved MCMC iterations per chain to run. |
quiet |
Logical of length 1, |
Details
The model is a simple Bayesian model with a normal likelihood,
an unknown mean mu
, and an unknown standard deviation sigma
.
For each historical study, the posterior mean of mu
becomes
the corresponding component of m_omega
in the output,
and the posterior standard deviation of mu
becomes the corresponding component of s_omega
in the output.
See the examples in this help file for a demonstration.
m_omega
and s_omega
define the components of the mixture prior
in hb_mcmc_mixture()
that act as the contribution of the
historical studies to the model.
Value
A tidy data frame of hyperparameter values for hb_mcmc_mixture()
.
The first several rows are for historical studies, and the last row
is for the current study. Studies/rows are sorted in the order
hb_mcmc_mixture()
sorts them, so you can use columns m_omega
and s_omega
for the same dataset and same values of other arguments
directly in hb_mcmc_mixture()
.
See Also
Other mcmc:
hb_convergence()
,
hb_mcmc_hierarchical()
,
hb_mcmc_independent()
,
hb_mcmc_mixture()
,
hb_mcmc_pool()
Examples
data_all_studies <- hb_sim_independent(n_continuous = 2)$data
data_all_studies$study <- paste0("study", data_all_studies$study)
hyperparameters <- hb_mcmc_mixture_hyperparameters(
data = data_all_studies,
response = "response",
study = "study",
study_reference = "study5",
group = "group",
group_reference = 1,
patient = "patient",
n_chains = 1,
n_adapt = 100,
n_warmup = 50,
n_iterations = 50
)
print(hyperparameters)
data_current_study <- dplyr::filter(data_all_studies, study == max(study))
hb_mcmc_mixture(
data = data_current_study,
response = "response",
study = "study",
study_reference = "study5",
group = "group",
group_reference = 1,
patient = "patient",
m_omega = hyperparameters$m_omega, # use hyperparams from historical data
s_omega = hyperparameters$s_omega, # use hyperparams from historical data
p_omega = rep(1 / nrow(hyperparameters), nrow(hyperparameters)),
n_chains = 1,
n_adapt = 100,
n_warmup = 50,
n_iterations = 50
)