Run a simple model separately on each historical study control group and compute hyperparameters for hb_mcmc_mixture().

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 m_omega and s_omega for the mixture model.

response

Character of length 1, name of the column in data with the response/outcome variable. data[[response]] must be a continuous variable, and it should be the change from baseline of a clinical endpoint of interest, as opposed to just the raw response. Treatment differences are computed directly from this scale, please supply change from baseline unless you are absolutely certain that treatment differences computed directly from this quantity are clinically meaningful.

study

Character of length 1, name of the column in data with the study ID.

study_reference

Atomic of length 1, element of the study column that indicates the current study. (The other studies are historical studies.)

group

Character of length 1, name of the column in data with the group ID.

group_reference

Atomic of length 1, element of the group column that indicates the control group. (The other groups may be treatment groups.)

patient

Character of length 1, name of the column in data with the patient ID.

m_mu

Numeric of length 1, prior mean of the mean mu in the simple model.

s_mu

Numeric of length 1, prior standard deviation of the mean mu in the simple model.

s_sigma

Numeric of length 1, uniform prior upper bound of the residual standard deviation sigma in the simple model.

m_omega_current

Numeric with length 1, m_omega value of the current study. Inserted as the final component of the m_omega column in the output.

s_omega_current

Numeric with length 1, s_omega value of the current study. Inserted as the final component of the s_omega column in the output.

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, TRUE to suppress R console output.

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().

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.

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)
#> # A tibble: 5 × 4
#>   study  study_index m_omega s_omega
#>   <chr>        <int>   <dbl>   <dbl>
#> 1 study1           1   0.975   0.166
#> 2 study2           2   1.51    0.103
#> 3 study3           3   0.821   0.252
#> 4 study4           4   1.29    0.216
#> 5 study5           5   0      30    
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
)
#> # A tibble: 50 × 19
#>    alpha beta[…¹ beta[…² delta…³ delta…⁴ omega…⁵ omega…⁶ omega…⁷ omega…⁸ omega…⁹
#>    <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#>  1 -1.78   0.365  -1.14    0.769   0.361   1.10     1.53   0.672   1.48    -1.78
#>  2 -1.60   0.384  -1.03    0.873   0.224   1.08     1.63   0.823   1.46    -1.60
#>  3 -1.73   0.356  -1.04    0.834   0.329   1.02     1.45   1.13    1.55    -1.73
#>  4 -1.54   0.369  -0.992   0.885   0.327   1.10     1.59   0.819   1.25    -1.54
#>  5 -1.61   0.337  -1.13    1.09    0.502   1.00     1.53   0.883   0.951   -1.61
#>  6 -1.67   0.374  -1.06    0.528   0.467   1.01     1.53   0.871   1.13    -1.67
#>  7 -1.63   0.399  -1.03    0.918   0.354   0.873    1.58   0.414   1.54    -1.63
#>  8 -1.56   0.355  -1.04    0.882   0.366   0.960    1.64   0.596   1.24    -1.56
#>  9 -1.53   0.406  -1.07    0.951   0.341   1.21     1.47   0.483   1.68    -1.53
#> 10 -1.69   0.392  -1.13    0.937   0.283   0.925    1.61   1.05    1.27    -1.69
#> # … with 40 more rows, 9 more variables: `post_p[1]` <dbl>, `post_p[2]` <dbl>,
#> #   `post_p[3]` <dbl>, `post_p[4]` <dbl>, `post_p[5]` <dbl>, sigma <dbl>,
#> #   .chain <int>, .iteration <int>, .draw <int>, and abbreviated variable names
#> #   ¹​`beta[1]`, ²​`beta[2]`, ³​`delta[1]`, ⁴​`delta[2]`, ⁵​`omega[1]`, ⁶​`omega[2]`,
#> #   ⁷​`omega[3]`, ⁸​`omega[4]`, ⁹​`omega[5]`