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.

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).

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 1.09 -0.713 -0.844 #> 2 -0.885 2.11 0.594 #> 3 0.675 0.390 0.417 #> 4 0.120 1.01 0.769 #> 5 -0.226 -1.25 -0.585 #> 6 -0.855 -0.156 -0.241 #> 7 -0.288 1.46 -1.22 #> 8 1.22 -0.600 -0.873 #> 9 -0.902 -0.543 -1.54 #> 10 -0.0511 0.617 -1.01 #> # ... with 490 more rows