Simulates a nested multilevel data structure. Lowest level can be used as observational error.
Arguments
- n_levels
Number of hierarchical levels (default: 3).
- n_units_perlevel
A vector specifying the number of units at each level (default: rep(25, n_levels)).
- sigma_perlevel
A vector specifying the standard deviation of etas at each level (default: rep(1, n_levels)).
- mu_global
Global mean for the outcome variable (default: 0).
- add_data
Logical indicating whether to add observations (default: TRUE). If TRUE, adds column y.
- n_data
Number of observations to add at the lowest level (default: 10).
- sigma_y
Standard deviation of the added observations (default: 0.05)
- add_data1levelup
Logical indicating whether to add observations one level up e.g. at national level if lowest level is subnational (default: FALSE).
- seed
Random seed for reproducibility (default: 1234).