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.

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 or dagitty object. default path coefficient applied to arrows for which no coefficient is defined in the model syntax. lower bound for random path coefficients, applied if b.default = NULL. upper bound for path coefficients. residual variance (only meaningful if standardized=FALSE). number of samples to generate. whether a standardized output is desired (all variables have variance 1).

Value

a tblwith N values for each variable in .tdy_dag

Examples

dagify(y ~ z, x ~ z) %>%
tidy_dagitty() %>%
simulate_data()#> # A tibble: 500 x 3
#>         x      y       z
#>     <dbl>  <dbl>   <dbl>
#>  1  0.380  2.02   1.82
#>  2 -0.658 -0.485 -0.480
#>  3 -1.67   0.820 -1.38
#>  4  0.626  0.905  1.23
#>  5  0.695 -0.975 -1.24
#>  6 -1.29   0.999  0.358
#>  7  1.49  -0.633  0.0465
#>  8 -1.04  -1.22   1.28
#>  9 -0.487 -1.52   0.341
#> 10 -0.506  1.22  -0.213
#> # ... with 490 more rows