Class HybridCgModel.HybridCgIm

java.lang.Object
edu.cmu.tetrad.hybridcg.HybridCgModel.HybridCgIm
All Implemented Interfaces:
Serializable
Enclosing class:
HybridCgModel

public static final class HybridCgModel.HybridCgIm extends Object implements Serializable
Represents a hybrid causal graph instantiated model (IM) derived from a hybrid causal graph probabilistic model (PM). This model supports both discrete and continuous variables and their dependencies, providing functionality for manipulating and generating data based on the underlying probabilistic structure.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    The HybridEstimator class estimates Hybrid Causal Graphical Models using Maximum Likelihood Estimation (MLE).
    static final record 
    Represents a sample containing continuous and discrete data arrays along with a specified number of rows.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a HybridCgIm instance from a HybridCgPm.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    getCoefficient(int nodeIndex, int rowIndex, int contParentOrderIndex)
    Retrieves the coefficient value for a continuous child node.
    double
    getMean(int nodeIndex, int rowIndex)
    Retrieves the mean value for a continuous child node.
    Retrieves the probabilistic model associated with this hybrid causal graph model.
    double
    getProbability(int nodeIndex, int rowIndex, int yCategory)
    Retrieves the probability of a specific category for a discrete child node.
    double
    getVariance(int nodeIndex, int rowIndex)
    Retrieves the variance value for a continuous child node.
    void
    normalizeRow(int nodeIndex, int rowIndex)
    Normalizes the probabilities in a row of the local table for a discrete child node.
    static int
    rowIndexForCase(HybridCgModel.HybridCgPm pm, int nodeIndex, DataSet data, int row, int[] colIndex)
    Computes the row index for a given data case in the hybrid causal graph model.
    sample(int n, Random rng)
    Simulate n rows from this IM.
    void
    setCoefficient(int nodeIndex, int rowIndex, int contParentOrderIndex, double v)
    Sets the coefficient value for a continuous child node.
    void
    setMean(int nodeIndex, int rowIndex, double v)
    Sets the mean value for a continuous child node.
    void
    setProbability(int nodeIndex, int rowIndex, int yCategory, double p)
    Sets the probability of a specific category for a discrete child node.
    void
    setVariance(int nodeIndex, int rowIndex, double v)
    Sets the variance value for a continuous child node.
    Convert a sampled matrix into a Tetrad DataSet with the provided node ordering.
    Returns a string representation of the HybridIm model.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • HybridCgIm

      public HybridCgIm(HybridCgModel.HybridCgPm pm)
      Constructs a HybridCgIm instance from a HybridCgPm.
      Parameters:
      pm - the probabilistic model
  • Method Details

    • rowIndexForCase

      public static int rowIndexForCase(HybridCgModel.HybridCgPm pm, int nodeIndex, DataSet data, int row, int[] colIndex)
      Computes the row index for a given data case in the hybrid causal graph model.
      Parameters:
      pm - the probabilistic model
      nodeIndex - the index of the node
      data - the dataset
      row - the row index in the dataset
      colIndex - the column indices for the parents
      Returns:
      the row index for the data case
    • getPm

      public HybridCgModel.HybridCgPm getPm()
      Retrieves the probabilistic model associated with this hybrid causal graph model.
      Returns:
      the probabilistic model represented by a HybridCgModel.HybridCgPm instance
    • getProbability

      public double getProbability(int nodeIndex, int rowIndex, int yCategory)
      Retrieves the probability of a specific category for a discrete child node.
      Parameters:
      nodeIndex - the index of the discrete child node
      rowIndex - the row index in the local table
      yCategory - the category index for the discrete child
      Returns:
      the probability of the specified category
    • setProbability

      public void setProbability(int nodeIndex, int rowIndex, int yCategory, double p)
      Sets the probability of a specific category for a discrete child node.
      Parameters:
      nodeIndex - the index of the discrete child node
      rowIndex - the row index in the local table
      yCategory - the category index for the discrete child
      p - the probability value to set
    • normalizeRow

      public void normalizeRow(int nodeIndex, int rowIndex)
      Normalizes the probabilities in a row of the local table for a discrete child node.
      Parameters:
      nodeIndex - the index of the discrete child node
      rowIndex - the row index in the local table
    • getMean

      public double getMean(int nodeIndex, int rowIndex)
      Retrieves the mean value for a continuous child node.
      Parameters:
      nodeIndex - the index of the continuous child node
      rowIndex - the row index in the local table
      Returns:
      the mean value
    • setMean

      public void setMean(int nodeIndex, int rowIndex, double v)
      Sets the mean value for a continuous child node.
      Parameters:
      nodeIndex - the index of the continuous child node
      rowIndex - the row index in the local table
      v - the mean value to set
    • getCoefficient

      public double getCoefficient(int nodeIndex, int rowIndex, int contParentOrderIndex)
      Retrieves the coefficient value for a continuous child node.
      Parameters:
      nodeIndex - the index of the continuous child node
      rowIndex - the row index in the local table
      contParentOrderIndex - the index of the continuous parent
      Returns:
      the coefficient value
    • setCoefficient

      public void setCoefficient(int nodeIndex, int rowIndex, int contParentOrderIndex, double v)
      Sets the coefficient value for a continuous child node.
      Parameters:
      nodeIndex - the index of the continuous child node
      rowIndex - the row index in the local table
      contParentOrderIndex - the index of the continuous parent
      v - the coefficient value to set
    • getVariance

      public double getVariance(int nodeIndex, int rowIndex)
      Retrieves the variance value for a continuous child node.
      Parameters:
      nodeIndex - the index of the continuous child node
      rowIndex - the row index in the local table
      Returns:
      the variance value
    • setVariance

      public void setVariance(int nodeIndex, int rowIndex, double v)
      Sets the variance value for a continuous child node.
      Parameters:
      nodeIndex - the index of the continuous child node
      rowIndex - the row index in the local table
      v - the variance value to set
    • toDataSet

      public DataSet toDataSet(HybridCgModel.HybridCgIm.Sample sample)
      Convert a sampled matrix into a Tetrad DataSet with the provided node ordering. The node list must be a permutation of the PM's nodes; types (discrete/continuous) are taken from the PM.
      Parameters:
      sample - the sampled matrix
      Returns:
      the Tetrad DataSet
    • sample

      public HybridCgModel.HybridCgIm.Sample sample(int n, Random rng)
      Simulate n rows from this IM.
      • Order: a topological order over the DAG is computed internally.
      • Discrete child with continuous parents: uses discretized bins of the parent values to select the CPT row.
      • Continuous child: for each discrete-parent stratum, samples from the fitted Gaussian regression.
      Parameters:
      n - number of rows to sample
      rng - random number generator
      Returns:
      sample
    • toString

      public String toString()
      Returns a string representation of the HybridIm model.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the HybridIm model