Learn R Programming

simcausal (version 0.1)

sim: Simulate from DAG or list of DAGs (Either Action or Observed DAG(s))

Description

This function simulates full data based on a list of intervention DAGs, returning a list of data.frames

Usage

sim(DAG, actions, n, wide = TRUE, LTCF = NULL, rndseed = NULL)

Arguments

DAG
A DAG objects that has been locked with set.DAG(DAG). Observed data from this DAG will be simulated if actions argument is omitted.
actions
Character vector of action names which will be extracted from the DAG object. Alternatively, this can be a list of action DAGs selected with A(DAG) function, in which case the argument DAG is unused. When this argument is missing
n
Number of observations to sample.
wide
A logical, if TRUE the output data is generated in wide format, if FALSE, the output longitudinal data in generated in long format
LTCF
The name of the right-censoring / failure event indicator variable for the Last Time-point Carried Forward imputation. By default, when LTCF is left unspecified, all variables that follow after any end of follow-up (EFU) event are set to missing (NA). The
rndseed
Seed for the random number generator.

Value

  • If actions argument is missing a simulated data.frame is returned, otherwise the function returns a named list of action-specific simulated data.frames with action names giving names to corresponding list items.