Description Usage Arguments Details Examples
Takes simulation parameters as inputs and returns simulated data.
1 2 3 4 
fixed 
One sided formula for fixed effects in the simulation. To suppress intercept add 1 to formula. 
random 
One sided formula for random effects in the simulation. Must be a subset of fixed. 
fixed_param 
Fixed effect parameter values (i.e. beta weights). Must be same length as fixed. 
random_param 
A list of named elements that must contain:
Optional elements are:

cov_param 
List of arguments to pass to the continuous generating function, must be the same order as the variables specified in fixed. This list does not include intercept, time, factors, or interactions. Required arguments include:
Optional arguments to the distribution functions are in a nested list, see the examples or vignettes for example code. 
n 
Cluster sample size. 
p 
Within cluster sample size. 
data_str 
Type of data. Must be "cross", "long", or "single". 
cor_vars 
A vector of correlations between variables. 
fact_vars 
A nested list of factor, categorical, or ordinal variable specification, each list must include:
Optional arguments include:
See also 
unbal 
A vector of sample sizes for the number of observations for each level 2 cluster. Must have same length as level two sample size n. Alternative specification can be TRUE, which uses additional argument, unbal_design. 
unbal_design 
When unbal = TRUE, this specifies the design for unbalanced simulation in one of two ways. It can represent the minimum and maximum sample size within a cluster via a named list. This will be drawn from a random uniform distribution with min and max specified. Secondly, the sample sizes within each cluster can be specified. This takes the form of a vector that must have the same length as the level two sample size. 
contrasts 
An optional list that specifies the contrasts to be used
for factor variables (i.e. those variables with .f or .c).
See 
outcome_type 
A vector specifying the type of outcome, must be either logistic or poisson. Logitstic outcome will be 0/1 and poisson outcome will be counts. 
cross_class_params 
A list of named parameters when cross classified data structures are desired. Must include the following arguments:

knot_args 
A nested list of named knot arguments. See

... 
Not currently used. 
Simulates data for the nested logistic regression models. Returns a data frame with ID variables, fixed effects, random effects, and many other variables to help when running simulation studies.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  # Longitudinal linear mixed model example
fixed < ~1 + time + diff + act + time:act
random < ~1 + time + diff
fixed_param < c(0.1, 0.2, 0.15, 0.5, 0.02)
random_param < list(random_var = c(7, 4, 2), rand_gen = 'rnorm')
cov_param < list(dist_fun = c('rnorm', 'rnorm'),
var_type = c("level1", "level2"),
opts = list(list(mean = 0, sd = 1.5),
list(mean = 0, sd = 4)))
n < 150
p < 30
data_str < "long"
temp_long < sim_glm(fixed, random, random3 = NULL, fixed_param,
random_param, random_param3 = NULL,
cov_param, k = NULL, n, p, data_str = data_str, outcome_type = 'logistic')

Loading required package: Matrix
Loading required package: dplyr
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
Loading required package: purrr
Loading required package: tidyr
Attaching package: 'tidyr'
The following object is masked from 'package:Matrix':
expand
Loading required package: tibble
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.