Class ConditionalGaussianScore
- All Implemented Interfaces:
Score, EffectiveSampleSizeSettable
Reference: Andrews, B., Ramsey, J., & Cooper, G. F. (2018). Scoring Bayesian networks of mixed variables. International Journal of Data Science and Analytics, 6, 3–18.
As for all scores in Tetrad, higher scores mean more dependence, and negative scores indicate independence.
Effective sample size (added 2026-8-25). Rows that are serially dependent, clustered, or interpolated carry less
evidence than independent rows. When an effective sample size nEff is set (see
setEffectiveSampleSize(int)), the local score is computed as if the data consisted of nEff independent
rows: the log-likelihood, which is a sum over rows, is scaled by r = nEff / N, where N is the number of rows in
the dataset, and the BIC penalty uses r times the number of rows actually scored. Under testwise deletion the rows
actually scored may be fewer than N; the ratio, not the absolute count, is what is preserved, so a family scored
on m complete rows behaves as if it had r * m independent rows. With nEff unset (or negative) r = 1 and the score
is unchanged from the previous implementation. Cell-size gates in the likelihood (minSampleSizePerCell)
are estimability checks on the raw rows and are not affected.
- Version:
- $Id: $Id
- Author:
- josephramsey
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConditionalGaussianScore(DataSet dataSet, double penaltyDiscount, boolean discretize) Constructs the score.ConditionalGaussianScore(DataSet dataSet, double penaltyDiscount, boolean discretize, MissingDataSpec spec) Constructs the score from a dataset with an explicit missing-data specification. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the effective sample size: the value set viasetEffectiveSampleSize(int), or the number of rows in the dataset if none has been set.intRecommended max degree (same heuristic used elsewhere).Declares this score's native missing-value support: test-wise deletion.doubleRetrieves the penalty discount value used in the scoring calculations.intSample size.Returns the list of variables.booleanisEffectEdge(double bump) FGES “effect edge” convention for this score bump.doublelocalScore(int i, int... parents) Local BIC score for child i with parents.doublelocalScoreDiff(int x, int y, int[] z) Score difference localScore(y | z ∪ {x}) - localScore(y | z).voidsetDiscretize(boolean discretize) Sets whether to discretize child variables for shadow discretization.voidsetEffectiveSampleSize(int nEff) Sets the effective sample size, or -1 (any negative value) to use the actual number of rows.voidsetMinSampleSizePerCell(int n) Sets the minimum sample size per cell for scoring calculations during the learning process.voidsetNumCategoriesToDiscretize(int numCategoriesToDiscretize) Sets the number of categories to be used for discretizing child variables in order to avoid integration.voidsetPenaltyDiscount(double penaltyDiscount) Updates the penalty discount value used in the scoring calculations.voidsetStructurePrior(double structurePrior) Sets the structure prior value for the scoring process.toString()Returns a string representation of the Conditional Gaussian Score Penalty.Methods inherited from interface Score
append, determines, getVariable, localScore, localScore, localScoreDiff
-
Constructor Details
-
ConditionalGaussianScore
Constructs the score.- Parameters:
dataSet- mixed (or all-continuous / all-discrete) datasetpenaltyDiscount- BIC penalty multiplierdiscretize- if true, use shadow discretization of continuous parents for discrete children
-
ConditionalGaussianScore
public ConditionalGaussianScore(DataSet dataSet, double penaltyDiscount, boolean discretize, MissingDataSpec spec) Constructs the score from a dataset with an explicit missing-data specification. If the spec is null and the dataset contains missing values, TESTWISE deletion is used (this score's historical behavior) and a warning is logged; see MissingDataUtils.resolveOrWarn.- Parameters:
dataSet- mixed (or all-continuous / all-discrete) datasetpenaltyDiscount- BIC penalty multiplierdiscretize- if true, use shadow discretization of continuous parents for discrete childrenspec- The missing-data specification, or null for the legacy default.- Throws:
IllegalArgumentException- If the policy is FAIL and the dataset has missing values, or if the policy is EM_COVARIANCE (all-continuous data only).UnsupportedOperationException- If the policy is MULTIPLE_IMPUTATION (handled by a search wrapper, not by a single score; see Phase 3).
-
-
Method Details
-
localScore
public double localScore(int i, int... parents) Local BIC score for child i with parents.- Specified by:
localScorein interfaceScore- Parameters:
i- child indexparents- parent indices- Returns:
- local BIC score for child i with parents
-
localScoreDiff
public double localScoreDiff(int x, int y, int[] z) Score difference localScore(y | z ∪ {x}) - localScore(y | z).- Specified by:
localScoreDiffin interfaceScore- Parameters:
x- index of the variable to add to the parentsy- index of the child variablez- array of parent indices- Returns:
- score difference
-
getSampleSize
public int getSampleSize()Sample size.- Specified by:
getSampleSizein interfaceScore- Returns:
- sample size
-
isEffectEdge
public boolean isEffectEdge(double bump) FGES “effect edge” convention for this score bump.- Specified by:
isEffectEdgein interfaceScore- Parameters:
bump- score bump- Returns:
- true if the score bump is positive, false otherwise
-
getVariables
Returns the list of variables.- Specified by:
getVariablesin interfaceScore- Returns:
- list of variables
-
getMaxDegree
public int getMaxDegree()Recommended max degree (same heuristic used elsewhere).- Specified by:
getMaxDegreein interfaceScore- Returns:
- the max degree.
-
getPenaltyDiscount
public double getPenaltyDiscount()Retrieves the penalty discount value used in the scoring calculations.- Returns:
- the penalty discount value as a double.
-
setPenaltyDiscount
public void setPenaltyDiscount(double penaltyDiscount) Updates the penalty discount value used in the scoring calculations.- Parameters:
penaltyDiscount- the new penalty discount value as a double
-
setNumCategoriesToDiscretize
public void setNumCategoriesToDiscretize(int numCategoriesToDiscretize) Sets the number of categories to be used for discretizing child variables in order to avoid integration.- Parameters:
numCategoriesToDiscretize- the number of categories to discretize child variables
-
setDiscretize
public void setDiscretize(boolean discretize) Sets whether to discretize child variables for shadow discretization. This affects scoring during the learning process to optimize calculations involving mixed data types.- Parameters:
discretize- A boolean value indicating whether to enable discretization. If true, enables discretization.
-
setMinSampleSizePerCell
public void setMinSampleSizePerCell(int n) Sets the minimum sample size per cell for scoring calculations during the learning process.- Parameters:
n- The minimum number of samples required per cell to guarantee stable computations.
-
setStructurePrior
public void setStructurePrior(double structurePrior) Sets the structure prior value for the scoring process.- Parameters:
structurePrior- The value of the structure prior to be used in scoring calculations.
-
getEffectiveSampleSize
public int getEffectiveSampleSize()Returns the effective sample size: the value set viasetEffectiveSampleSize(int), or the number of rows in the dataset if none has been set.- Specified by:
getEffectiveSampleSizein interfaceEffectiveSampleSizeSettable- Returns:
- the effective sample size
-
setEffectiveSampleSize
public void setEffectiveSampleSize(int nEff) Sets the effective sample size, or -1 (any negative value) to use the actual number of rows. A value of 0 is treated as unset, since a zero effective sample size is meaningless. The value is interpreted relative to the full dataset; see the class Javadoc for how it interacts with testwise deletion.Configuration mutator: do not call concurrently with running searches.
- Specified by:
setEffectiveSampleSizein interfaceEffectiveSampleSizeSettable- Parameters:
nEff- the effective sample size, or a nonpositive value to use the actual number of rows
-
toString
Returns a string representation of the Conditional Gaussian Score Penalty. The representation includes the penalty discount formatted to two decimal places. -
getMissingValueSupport
Declares this score's native missing-value support: test-wise deletion.- Specified by:
getMissingValueSupportin interfaceScore- Returns:
- This support level.
-