simobs: Simulate Observed Data

View source: R/simulation.r

simobsR Documentation

Simulate Observed Data

Description

This function simulates observed data from a DAG object.

Usage

simobs(DAG, n, wide = TRUE, LTCF = NULL, rndseed = NULL,
  rndseed.reset.node = NULL, verbose = getOption("simcausal.verbose"))

Arguments

DAG

A DAG objects that has been locked with set.DAG(DAG). Observed data from this DAG will be simulated.

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

If forward imputation is desired for the missing variable values, this argument should be set to the name of the node that indicates the end of follow-up event. See the vignette, sim and doLTCF for additional details.

rndseed

Seed for the random number generator.

rndseed.reset.node

When rndseed is specified, use this argument to specify the name of the DAG node at which the random number generator seed is reset back to NULL (simulation function will call set.seed(NULL)). Can be useful if one wishes to simulate data using the set seed rndseed only for the first K nodes of the DAG and use an entirely random sample when simulating the rest of the nodes starting at K+1 and on. The name of such (K+1)th order DAG node should be then specified with this argument.

verbose

Set to TRUE to print messages on status and information to the console. Turn this off by default using options(simcausal.verbose=FALSE).

Value

A data.frame where each column is sampled from the conditional distribution specified by the corresponding DAG object node.

See Also

simfull - a wrapper function for simulating full data only; sim - a wrapper function for simulating both types of data; doLTCF for forward imputation of the missing values in already simulating data; DF.to.long, DF.to.longDT - converting longitudinal data from wide to long formats.

Other simulation functions: simfull, sim


osofr/simcausal documentation built on Oct. 21, 2022, 3:09 a.m.