Class DaoSimulation

java.lang.Object
edu.cmu.tetrad.algcomparison.simulation.DaoSimulation
All Implemented Interfaces:
Simulation, HasParameters, TetradSerializable, Serializable

public class DaoSimulation extends Object implements Simulation
Implements the DAG-adaptation of the Onion (DaO) simulation method for generating linear data from a DAG, with exogenous errors drawn from one of the reference implementation's five variance-matched families (Gaussian by default; Exponential, Gumbel, Laplace, or Uniform via daoErrorDistribution), as described in:

Andrews, B. & Kummerfeld, E. (2024). "Better Simulations for Validating Causal Discovery with the DAG-Adaptation of the Onion Method." arXiv:2405.13100.

Reference Python implementation: ...

The key idea is to sample the correlation matrix R uniformly over the space of all correlation matrices satisfying the Markov property for the given DAG, rather than sampling edge weights directly (as most other simulations do). This avoids simulation artifacts such as varsortability and R²-sortability.

The algorithm proceeds in topological order over the DAG. For each non-source variable i with parents pa(i), it:

  1. Builds a permutation matrix P that puts parents first among predecessors.
  2. Computes the Cholesky factor L of the permuted sub-correlation matrix.
  3. Samples w from the multivariate Pearson Type II distribution mPII_k(gamma), with nonzero entries only in the first k (parent) slots.
  4. Recovers marginal correlations r = P L w, structural coefficients b = P L^{-T} w, and error variance o = 1 - w^T w.

Optional graph-rewiring steps:

  • daoSfOut — rewires to produce a scale-free out-degree distribution
  • daoSfIn — rewires to produce a scale-free in-degree distribution
  • daoRandomizeOrder — randomly permutes variable order after rewiring
Author:
Bryan Andrews (algorithm); Java translation for Tetrad
See Also:
  • Constructor Details

    • DaoSimulation

      public DaoSimulation(RandomGraph randomGraph)
      Constructs a DaoSimulation using the supplied RandomGraph to produce the true DAG on each run.
      Parameters:
      randomGraph - source of true DAGs; must not be null.
    • DaoSimulation

      public DaoSimulation(Graph trueGraph)
      Convenience constructor that fixes a single, predetermined true DAG.
      Parameters:
      trueGraph - the DAG to use for every run; must not be null.
  • Method Details

    • createData

      public void createData(Parameters parameters, boolean newModel)
      Creates a data set and simulates data.

      Creates NUM_RUNS data sets, each drawn from the DaO method applied to the true DAG. If DIFFERENT_GRAPHS is true, a fresh DAG is generated for each run.

      Specified by:
      createData in interface Simulation
      Parameters:
      parameters - The parameters to use in the simulation.
      newModel - If true, a new model is created. If false, the model is reused.
    • getTrueGraph

      public Graph getTrueGraph(int index)
      Description copied from interface: Simulation
      Returns the true graph at the given index.
      Specified by:
      getTrueGraph in interface Simulation
      Parameters:
      index - The index of the desired true graph.
      Returns:
      That graph.
    • getNumDataModels

      public int getNumDataModels()
      Description copied from interface: Simulation
      Returns the number of data models.
      Specified by:
      getNumDataModels in interface Simulation
      Returns:
      The number of data sets to simulate.
    • getDataModel

      public DataModel getDataModel(int index)
      Description copied from interface: Simulation
      Returns the number of data sets to simulate.
      Specified by:
      getDataModel in interface Simulation
      Parameters:
      index - The index of the desired simulated data set.
      Returns:
      That data set.
    • getDataType

      public DataType getDataType()
      Description copied from interface: Simulation
      Returns the data type of the data.
      Specified by:
      getDataType in interface Simulation
      Returns:
      Returns the type of the data, continuous, discrete or mixed.
    • getDescription

      public String getDescription()
      Description copied from interface: Simulation
      Returns the description of the simulation.
      Specified by:
      getDescription in interface Simulation
      Returns:
      Returns a one-line description of the simulation, to be printed at the beginning of the report.
    • getShortName

      public String getShortName()
      Description copied from interface: Simulation
      Returns the short name of the simulation.
      Specified by:
      getShortName in interface Simulation
      Returns:
      The short name of the simulation.
    • getParameters

      public List<String> getParameters()
      Description copied from interface: Simulation
      Returns the list of parameters used in the simulation.
      Specified by:
      getParameters in interface HasParameters
      Specified by:
      getParameters in interface Simulation
      Returns:
      Returns the parameters used in the simulation. These are the parameters whose values can be varied.
    • getRandomGraphClass

      public Class<? extends RandomGraph> getRandomGraphClass()
      Description copied from interface: Simulation
      Retrieves the class of a random graph for the simulation.
      Specified by:
      getRandomGraphClass in interface Simulation
      Returns:
      The class of a random graph for the simulation.
    • getSimulationClass

      public Class<? extends Simulation> getSimulationClass()
      Description copied from interface: Simulation
      Returns the class of the simulation. This method is used to retrieve the class of a simulation based on the selected simulations in the model.
      Specified by:
      getSimulationClass in interface Simulation
      Returns:
      The class of the simulation.
    • soficOrder

      public static List<Node> soficOrder(Graph dag)
      Returns a source-first consistent topological ordering of the DAG nodes. Translation of Python sofic_order(g): sources are placed first, then each node is appended once all its parents have been placed.
      Parameters:
      dag - the DAG
      Returns:
      nodes in source-first topological order