simDAG: Simulate a random DAG
Description
Simulates a random directed acyclic graph adjacency (DAG) matrix with
the provided edge sparsity. The edge sparsity is the percentage of edges
that are absent, relative to a fully connected DAG.
Usage
simDAG(p, sparsity = NULL, sparsityLim = c(0, 0.8), permute = TRUE)
Value
An adjacency matrix.
Arguments
- p
The number of nodes.
- sparsity
If NULL (the default), a random edge sparsity
is sampled from the interval provided in sparsityLim. Otherwise,
the sparsity should be provided as a numeric in [0,1].
- sparsityLim
A vector of two numerics, both must be in [0,1].
- permute
If FALSE, the adjacency matrix will include nodes
in their causal ordering. This is avoided by setting permute = TRUE,
in which case the node order is permuted randomly.
Examples
Run this code# Simulate a DAG adjacency matrix with 5 nodes
simDAG(5)
Run the code above in your browser using DataLab