Learn R Programming

simglm (version 0.8.0)

sim_fixef_nested3: Simulates design matrix.

Description

Input fixed variables, sample size, and number of within variables, returns design matrix.

Usage

sim_fixef_nested3(
  fixed,
  fixed_vars,
  cov_param,
  k,
  n,
  p,
  data_str,
  cor_vars = NULL,
  fact_vars = list(NULL),
  contrasts = NULL,
  knot_args = list(NULL)
)

Arguments

fixed

One sided formula for fixed effects in the simulation.

fixed_vars

Character vector of covariates for design matrix.

cov_param

List of arguments. Required arguments are:

  • dist_fun: This is a quoted R distribution function.

  • var_type: This is the level of variable to generate. Must be either 'level1', 'level2', or 'level3'. Must be same order as fixed formula above.

Optional arguments to the distribution functions are in a nested list, see the examples for example code for this. Does not include intercept, time, factors, or interactions.

k

Number of third level clusters.

n

Number of clusters.

p

Number of within cluster units.

data_str

Type of data. Must be "cross", or "long".

cor_vars

A vector of correlations between variables.

fact_vars

A nested list of factor, categorical, or ordinal variable specification, each list must include:

  • numlevels = Number of levels for ordinal or factor variables.

  • var_type = Must be 'level1', 'level2', or 'level3'.

Optional arguments passed on to sample in a nested list. These include:

  • replace

  • prob

  • value.labels

See also sample for use of these optional arguments.

contrasts

An optional list that specifies the contrasts to be used for factor variables (i.e. those variables with .f or .c). See contrasts for more detail.

knot_args

A nested list of named knot arguments. See sim_knot for more details. Arguments must include:

  • var

  • knot_locations

Details

Simulates the fixed effects for the sim_reg function when a linear mixed model is specified. This function assumes a time variable when longitudinal data is specified and does include any interactions that are specified.