Package edu.cmu.tetrad.hybridcg
Class HybridCgModel.HybridCgIm
java.lang.Object
edu.cmu.tetrad.hybridcg.HybridCgModel.HybridCgIm
- All Implemented Interfaces:
Serializable
- Enclosing class:
HybridCgModel
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 ClassesModifier and TypeClassDescriptionstatic final classThe HybridEstimator class estimates Hybrid Causal Graphical Models using Maximum Likelihood Estimation (MLE).static final recordRepresents a sample containing continuous and discrete data arrays along with a specified number of rows. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a HybridCgIm instance from a HybridCgPm. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetCoefficient(int nodeIndex, int rowIndex, int contParentOrderIndex) Retrieves the coefficient value for a continuous child node.doublegetMean(int nodeIndex, int rowIndex) Retrieves the mean value for a continuous child node.getPm()Retrieves the probabilistic model associated with this hybrid causal graph model.doublegetProbability(int nodeIndex, int rowIndex, int yCategory) Retrieves the probability of a specific category for a discrete child node.doublegetVariance(int nodeIndex, int rowIndex) Retrieves the variance value for a continuous child node.voidnormalizeRow(int nodeIndex, int rowIndex) Normalizes the probabilities in a row of the local table for a discrete child node.static introwIndexForCase(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.Simulatenrows from this IM.voidsetCoefficient(int nodeIndex, int rowIndex, int contParentOrderIndex, double v) Sets the coefficient value for a continuous child node.voidsetMean(int nodeIndex, int rowIndex, double v) Sets the mean value for a continuous child node.voidsetProbability(int nodeIndex, int rowIndex, int yCategory, double p) Sets the probability of a specific category for a discrete child node.voidsetVariance(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.toString()Returns a string representation of the HybridIm model.
-
Constructor Details
-
HybridCgIm
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 modelnodeIndex- the index of the nodedata- the datasetrow- the row index in the datasetcolIndex- the column indices for the parents- Returns:
- the row index for the data case
-
getPm
Retrieves the probabilistic model associated with this hybrid causal graph model.- Returns:
- the probabilistic model represented by a
HybridCgModel.HybridCgPminstance
-
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 noderowIndex- the row index in the local tableyCategory- 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 noderowIndex- the row index in the local tableyCategory- the category index for the discrete childp- 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 noderowIndex- 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 noderowIndex- 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 noderowIndex- the row index in the local tablev- 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 noderowIndex- the row index in the local tablecontParentOrderIndex- 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 noderowIndex- the row index in the local tablecontParentOrderIndex- the index of the continuous parentv- 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 noderowIndex- 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 noderowIndex- the row index in the local tablev- the variance value to set
-
toDataSet
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
Simulatenrows 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 samplerng- random number generator- Returns:
- sample
-
toString
Returns a string representation of the HybridIm model.
-