This is a thin wrapper for the simulateSEM()
function in dagitty
that works with tidied dagitty objects. It treats the input DAG as a
structural equation model, generating random path coefficients and simulating
corresponding data. See dagitty::simulateSEM()
for
details.
Usage
simulate_data(
.tdy_dag,
b.default = NULL,
b.lower = -0.6,
b.upper = 0.6,
eps = 1,
N = 500,
standardized = TRUE
)
Arguments
- .tdy_dag
A
tidy_dagitty
ordagitty
object- b.default
default path coefficient applied to arrows for which no coefficient is defined in the model syntax.
- b.lower
lower bound for random path coefficients, applied if b.default = NULL.
- b.upper
upper bound for path coefficients.
- eps
residual variance (only meaningful if standardized=FALSE).
- N
number of samples to generate.
- standardized
whether a standardized output is desired (all variables have variance 1).
Examples
dagify(y ~ z, x ~ z) |>
tidy_dagitty() |>
simulate_data()
#> # A tibble: 500 × 3
#> x y z
#> <dbl> <dbl> <dbl>
#> 1 -0.383 -2.22 -0.0400
#> 2 0.0473 -0.402 -0.842
#> 3 -0.931 0.307 -0.632
#> 4 -0.623 -0.720 0.683
#> 5 0.0468 1.36 1.38
#> 6 0.0374 1.25 -0.307
#> 7 0.186 -0.605 -1.01
#> 8 -1.63 0.288 -0.974
#> 9 -0.501 0.689 -1.04
#> 10 0.617 -1.27 -0.123
#> # ℹ 490 more rows