hb_mcmc_hierarchical {historicalborrow} | R Documentation |
Hierarchical model MCMC
Description
Run the hierarchical model with MCMC.
Usage
hb_mcmc_hierarchical(
data,
response = "response",
study = "study",
study_reference = max(data[[study]]),
group = "group",
group_reference = min(data[[group]]),
patient = "patient",
covariates = grep("^covariate", colnames(data), value = TRUE),
s_delta = 30,
s_beta = 30,
s_sigma = 30,
s_mu = 30,
s_tau = 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 |
covariates |
Character vector of column names
in |
s_delta |
Numeric of length 1, prior standard deviation
of the study-by-group effect parameters |
s_beta |
Numeric of length 1, prior standard deviation
of the fixed effects |
s_sigma |
Numeric of length 1, prior upper bound of the residual standard deviations. |
s_mu |
Positive numeric of length 1,
hyperparameter: prior standard deviation of the
mean |
s_tau |
Positive numeric of length 1,
hyperparameter: uniform prior upper bound of the
standard deviation |
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, |
Value
A tidy data frame of parameter samples from the
posterior distribution. Columns .chain
, .iteration
,
and .draw
have the meanings documented in the
posterior
package.
See Also
Other mcmc:
hb_convergence()
,
hb_mcmc_independent()
,
hb_mcmc_mixture_hyperparameters()
,
hb_mcmc_mixture()
,
hb_mcmc_pool()
Examples
if (!identical(Sys.getenv("HB_TEST", unset = ""), "")) {
data <- hb_sim_hierarchical(n_continuous = 2)$data
hb_mcmc_hierarchical(
data,
n_chains = 1,
n_adapt = 100,
n_warmup = 50,
n_iterations = 50
)
}