gen_multilevel: Generate simulated data for multilevel models

View source: R/Data.R

gen_multilevelR Documentation

Generate simulated data for multilevel models

Description

Generate simulated data for multilevel models

Usage

gen_multilevel(
  n = 25,
  m = 6,
  sigma_e = 2,
  sigma_u0 = 2,
  sigma_u1 = 2,
  sigma_u01 = -2,
  beta0 = 0,
  beta1 = 2,
  x.jitter = 0.5,
  seed = NULL
)

Arguments

n

Sample size. Input either a single number for a balanced data set, or a vector of length m indicating the sample size in each group.

m

Number of groups/levels.

sigma_e

The standard deviation of the errors.

sigma_u0

The standard deviation of the random intercept.

sigma_u1

The standard deviation of the random slopes.

sigma_u01

The covariance of between the random intercept and the random slope.

beta0

The mean of the random intercept.

beta1

The mean of the random slope.

x.jitter

A small amount of jitter is added to the X variables generated from a normal distribution with mean zero and standard deviation equal to x.jitter.

seed

(Optional) Random seed.

Value

A dataframe containing the response variable y, the unidimensional explanatory variables X, and the levels/groups (factors).

Examples

gen_multilevel()


haziqjamil/iprior documentation built on April 2, 2024, 5:26 p.m.