Learn R Programming

causalDisco (version 0.9.5)

simGausFromDAG: Simulate Gaussian data according to DAG

Description

Simulates a jointly Gaussian dataset given a DAG adjacency matrix ("from-to" encoding, see amat for details). The data is simulated using linear structural equations and the parameters (residual standard deviations and regression coefficients) are sampled from chosen intervals.

Usage

simGausFromDAG(
  amat,
  n,
  regparLim = c(0.5, 2),
  resSDLim = c(0.1, 1),
  pnegRegpar = 0.4,
  standardize = FALSE
)

Value

A data.frame of identically distributed simulated observations.

Arguments

amat

An adjacency matrix.

n

The number of observations that should be simulated.

regparLim

The interval from which regression parameters are sampled.

resSDLim

The interval from which residual standard deviations are sampled.

pnegRegpar

The probability of sampling a negative regression parameter.

standardize

If FALSE (the default), the raw data are returned. If TRUE, the data are first standardized, i.e., each variable will have its mean subtracted and be divided by its standard deviation.

Details

A variable \(X_{i}\) is simulated as
\(X_{i} := \sum_{Z \in pa(X_{i})} \beta_{Z} * Z + e_{i}\)
where \(pa(X_{i})\) are the parents of \(X_{i}\) in the DAG. The residual, \(e_{i}\), is drawn from a normal distribution.

Examples

Run this code
# Simulate DAG adjacency matrix with 6 nodes
ex_dag <- simDAG(6) 

# Simulate Gaussian data (100 iid observations) 
ex_data <- simGausFromDAG(ex_dag, n = 100)

Run the code above in your browser using DataLab