Skip to contents

Simulates a dataset from one or more model formulas using [lavaan::simulateData()]. Multiple formulas supplied through `...` are combined into a single lavaan model specification.

Usage

sdag(..., n = 100, standardized = TRUE, empirical = FALSE)

Arguments

...

One or more model formulas describing the data-generating model. Each formula must use syntax compatible with [lavaan::simulateData()].

n

A positive integer indicating the number of observations to simulate. Defaults to `100`.

standardized

Logical. If `TRUE`, model parameters are interpreted so that the observed variables have unit variances. Passed to the `standardized` argument of [lavaan::simulateData()].

empirical

Logical. If `TRUE`, the generated sample statistics match the model-implied population values exactly. Passed to the `empirical` argument of [lavaan::simulateData()].

Value

A data frame containing the simulated variables, with `n` rows.

See also

[lavaan::simulateData()]

Examples

sdag(
  y ~ 0.5 * x,
  x ~~ 1 * x,
  y ~~ 0.75 * y,
  n = 200
)
#> Error in loadNamespace(x): there is no package called ‘lavaan’

sdag(
  m ~ 0.4 * x,
  y ~ 0.3 * x + 0.5 * m,
  n = 500,
  empirical = TRUE
)
#> Error in loadNamespace(x): there is no package called ‘lavaan’