sem_sim: Simulate structural equation processes

View source: R/sem_sim.R

sem_simR Documentation

Simulate structural equation processes

Description

Generates samples from a structural causal model (SCM). In scm_sim, the DAG is implemented by formulas, with the response variable on the left and the value to be calculated. on the right.

Usage

sem_sim(story = NULL, ..., samp_n = 5)

Arguments

story

Optional list containing formulas and/or label names

...

more formulas describing the process and/or label names

samp_n

Integer giving the number of rows in the output

Details

You can set the exogenous random component of any variable by using the desired r____() random number generator with samp_n as the value of size.

A label name can be an element of ... or story. This label will be used to denote the observed value if the underlying variable is 1. (o or 0 is used otherwise.)

Examples

sem_sim(X ~ rnorm(samp_n), Y ~ 10 + runif(samp_n) + 5 * X, samp_n = 20)
sem_sim(X ~ 0, Y ~ 10* X - 1, Z ~ - 3 + 10 * Y, X = 1, Y = "murder", Z = "telegraph", samp_n = 50)


dtkaplan/SDSdata documentation built on June 28, 2022, 8:09 a.m.