Simulate from the non-longitudinal hierarchical model.
Usage
hb_sim_hierarchical(
n_study = 5,
n_group = 3,
n_patient = 100,
n_continuous = 0,
n_binary = 0,
s_delta = 1,
s_beta = 1,
s_sigma = 1,
s_mu = 1,
s_tau = 1,
d_tau = 4,
prior_tau = "half_t",
alpha = NULL,
delta = stats::rnorm(n = n_group - 1, mean = 0, sd = s_delta),
beta = stats::rnorm(n = n_study * (n_continuous + n_binary), mean = 0, sd = s_delta),
sigma = stats::runif(n = n_study, min = 0, max = s_sigma),
mu = stats::rnorm(n = 1, mean = 0, sd = s_mu),
tau = NULL
)Arguments
- n_study
Number of studies to simulate.
- n_group
Number of groups (e.g. study arms) to simulate per study.
- n_patient
Number of patients to simulate per study per group.
- n_continuous
Number of continuous covariates to simulate (all from independent standard normal distributions).
- n_binary
Number of binary covariates to simulate (all from independent Bernoulli distributions with p = 0.5).
- s_delta
Numeric of length 1, prior standard deviation of the study-by-group effect parameters
delta.- s_beta
Numeric of length 1, prior standard deviation of the fixed effects
beta.- s_sigma
Numeric of length 1, prior upper bound of the residual standard deviations.
- s_mu
Numeric of length 1, prior standard deviation of
mu.- s_tau
Non-negative numeric of length 1. If
prior_tauis"half_t", thens_tauis the scale parameter of the Student t prior oftauand analogous to thesigmaparameter of the Student-t parameterization given at https://mc-stan.org/docs/functions-reference/unbounded_continuous_distributions.html. # nolint Ifprior_tauis"uniform", thens_tauis the upper bound oftau. Upper bound ontauifprior_tauis"uniform".- d_tau
Positive numeric of length 1. Degrees of freedom of the Student t prior of
tauifprior_tauis"half_t".- prior_tau
Character string, family of the prior of
tau. Ifprior_tauequals"uniform", then the prior ontauis a uniform prior with lower bound 0 and upper bounds_tau. Ifprior_tauequals"half_t", then the prior ontauis a half Student-t prior with center 0, lower bound 0, scale parameters_tau, and degrees of freedomd_tau. The scale parameters_tauis analogous to thesigmaparameter of the Student-t parameterization given at https://mc-stan.org/docs/functions-reference/unbounded_continuous_distributions.html. # nolint- alpha
Numeric vector of length 1 for the pooled and mixture models and length
n_studyfor the independent and hierarchical models.alphais the vector of control group mean parameters.alphaenters the model by multiplying with$matrices$x_alpha(see the return value). The control group in the data is the one with thegroupcolumn equal to 1.- delta
Numeric vector of length
n_group - 1of treatment effect parameters.deltaenters the model by multiplying with$matrices$x_delta(see the return value). The control (non-treatment) group in the data is the one with thegroupcolumn equal to 1.- beta
Numeric vector of
n_study * (n_continuous + n_binary)fixed effect parameters. Within each study, the firstn_continuousbetas are for the continuous covariates, and the rest are for the binary covariates. All thebetas for one study appear before all thebetas for the next study, and studies are arranged in increasing order of the sorted unique values in$data$studyin the output.betasenters the model by multiplying with$matrices$x_alpha(see the return value).- sigma
Numeric vector of
n_studystudy-specific residual standard deviations.- mu
Numeric of length 1, mean of the control group means
alpha.- tau
Numeric of length 1, standard deviation of the control group means
alpha.
Value
A list with the following elements:
data: tidy long-form dataset with the patient-level data. one row per patient and indicator columns for the study, group (e.g. treatment arm), and patient ID. Theresponsecolumns is the patient response. The other columns are baseline covariates. The control group is the one with thegroupcolumn equal to 1, and the current study (non-historical) is the one with the maximum value of thestudycolumn. Only the current study has any non-control-group patients, the historical studies have only the control group.parameters: named list of model parameter values. See the model specification vignette for details.matrices: A named list of model matrices. See the model specification vignette for details.
See also
Other simulate:
hb_sim_independent(),
hb_sim_mixture(),
hb_sim_pool()
Examples
hb_sim_hierarchical()$data
#> # A tibble: 700 × 4
#> study group patient response
#> <int> <int> <int> <dbl>
#> 1 1 1 1 1.96
#> 2 1 1 2 2.09
#> 3 1 1 3 1.82
#> 4 1 1 4 2.18
#> 5 1 1 5 2.31
#> 6 1 1 6 2.30
#> 7 1 1 7 2.38
#> 8 1 1 8 2.26
#> 9 1 1 9 2.13
#> 10 1 1 10 2.17
#> # ℹ 690 more rows