Learn R Programming

simglm (version 0.8.0)

sim_fixef_single: Simulates design matrix for single level model.

Description

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

Usage

sim_fixef_single(
  fixed,
  fixed_vars,
  n,
  cov_param,
  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.

n

Number of clusters.

cov_param

List of arguments to pass to the continuous generating function. Required arguments include:

  • dist_fun: This is a quoted R distribution function.

  • var_type: This is the level of variable to generate. Must be 'single'. 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.

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 'single'.

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 simulating a simple regression model.