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
the input DAG, which can be 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.360 2.99 0.782
#> 2 0.435 -0.965 0.534
#> 3 -0.440 0.168 -0.895
#> 4 -0.359 -0.252 0.0641
#> 5 0.189 -0.202 -1.00
#> 6 -0.0368 0.212 1.48
#> 7 -0.502 0.979 0.916
#> 8 -0.108 1.37 1.61
#> 9 -1.83 -0.542 -0.683
#> 10 0.541 0.572 -1.07
#> # ℹ 490 more rows