mixed_model: Generate simulated mixed model data

Description Usage Arguments Examples

View source: R/mixed_model.R

Description

Generate simulated mixed model data

Usage

1
mixed_model(fixed, random, sigma, clusters, n_per, vars)

Arguments

fixed

a vector equal to the number of variables + 1. Each entry indicates the (standardized) value of the fixed effect. The first entry is for the intercept.

random

a vector equal to the number of variables + 1. Each entry indicates the (standardized) standard deviation for the random effects. The first entry is for the intercept.

sigma

proportion of variance remaining unexplained at the residual level

clusters

number of clusters

n_per

a vector of length two, indicating the mean and standard deviation of the number of observations within each cluster

vars

a named list. The names correspond to the variable names (including the cluster names). Each entry either contains a vector of three (indicating mean, standard deviation, and # of digits to round), or a vector containing the unique values of categorical variables. Also, you must include the name of the cluster. See examples.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# simulate data where depression = stress + life_events + parental_depression + ses
fixed = c(0, .2, .5, .3, .2)
random = c(.1, .1, 0, .2, .1)
vars = list(
 depression = c(10, 3, 0),
 stress = c(22, 7, 0),
 life_events = c("no", "yes"),
 parental_depression = c("no", "mild", "moderate", "severe"),
 ses = c(55, 15, 0),
 therapist = paste0("Dr. ", LETTERS[1:15])
)
mixed_model(fixed, random, sigma = .3, clusters=15, n_per = c(11, 3), vars=vars)

dustinfife/bluepill documentation built on Oct. 27, 2021, 12:08 p.m.