simulate tibble of two-level data with outcome, id_vector, and categorical/continuous covariates with varied magnitudes of effect. Nuisance predictors (orthogonal to outcome) also included.

sim_multilevel(
  j = 116,
  intercept_1 = 0,
  residual_var_sd_1 = 0.4,
  random_int_mean_2 = 0,
  residual_var_sd_2 = 0.1,
  start_seed = 713,
  num_in_groups = rpois(n = j, lambda = 15)
)

Arguments

j

integer—number level 2 units

intercept_1

double—intercept at level 1

residual_var_sd_1

double—standard deviation of residuals at level 1

random_int_mean_2

double—mean of random intercept at level 2

residual_var_sd_2

double—standard deviation of random intercept at level 2,

start_seed

integer—starting seed,

num_in_groups

numeric vector—number of observations per group length of argument j

Value

tibble

Examples

   J <- 116
   dat <-
      sim_multilevel(
         j = J,
         intercept_1 = 0,
         residual_var_sd_1 = 0.7,
         random_int_mean_2 = 0,
         residual_var_sd_2 = 0.3,
         start_seed = 713,
         num_in_groups = rpois(n = J, lambda = 15)
        )