Class ConditionalGaussianLikelihood
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.
- Version:
- $Id: $Id
- Author:
- bryanandrews, josephramsey
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classGives return value for a conditional Gaussian likelihood, returning a likelihood value and the degrees of freedom for it. -
Constructor Summary
ConstructorsConstructorDescriptionConditionalGaussianLikelihood(DataSet dataSet) Constructs the score using a covariance matrix. -
Method Summary
Modifier and TypeMethodDescriptiongetLikelihood(int i, int[] parents) Returns the likelihood of variable i conditional on the given parents, assuming the continuous mixedVariables index by i or by the parents are jointly Gaussian conditional on the discrete comparison.getLikelihood(int i, int[] parents, List<Integer> rows) AsgetLikelihood(int, int[]), but evaluated over exactly the given rows, passed explicitly so that concurrent callers (parallel FGES / BOSS scoring with testwise deletion) do not need to mutate shared state viasetRows(List).getLikelihoodRatio(int i, int[] parents0, int[] parents1) Returns the likelihood-ratio ingredients for the nested comparison of target i given parents0 (the smaller model) versus target i given parents1 (the larger model; parents0 should be a subset of parents1).getLikelihoodRatio(int i, int[] parents0, int[] parents1, List<Integer> rows) AsgetLikelihoodRatio(int, int[], int[]), but evaluated over exactly the given rows, passed explicitly so that concurrent callers (the parallelized Markov checker, parallel constraint-based search) do not need to mutate shared state viasetRows(List).voidsetDiscretize(boolean discretize) Sets whether to discretize child variables to avoid integration.voidsetMinSampleSizePerCell(int minSampleSizePerCell) Sets the minimum sample size per cell.voidsetNumCategoriesToDiscretize(int numCategoriesToDiscretize) Sets the number of categories to use to discretize child variables to avoid integrationvoidSets the rows to be used in the table.
-
Constructor Details
-
ConditionalGaussianLikelihood
Constructs the score using a covariance matrix.- Parameters:
dataSet- The continuous dataset to analyze.
-
-
Method Details
-
setRows
-
getLikelihood
Returns the likelihood of variable i conditional on the given parents, assuming the continuous mixedVariables index by i or by the parents are jointly Gaussian conditional on the discrete comparison.- Parameters:
i- The index of the conditioned variable.parents- The indices of the conditioning mixedVariables.- Returns:
- The likelihood.
-
getLikelihood
AsgetLikelihood(int, int[]), but evaluated over exactly the given rows, passed explicitly so that concurrent callers (parallel FGES / BOSS scoring with testwise deletion) do not need to mutate shared state viasetRows(List). Added 2026-8-12; setRows remains supported for callers that use it.- Parameters:
i- The index of the conditioned variable.parents- The indices of the conditioning mixedVariables.rows- The rows over which to evaluate.- Returns:
- The likelihood.
-
getLikelihoodRatio
Returns the likelihood-ratio ingredients for the nested comparison of target i given parents0 (the smaller model) versus target i given parents1 (the larger model; parents0 should be a subset of parents1). The returned Ret holds lik = [conditional log-likelihood under the larger model] minus [conditional log-likelihood under the smaller model] and dof = [dof of the larger conditional] minus [dof of the smaller conditional], both computed on a COMMON row support, so that 2 * lik is a genuine nested LRT statistic referable to chi-square(dof). Added 2026-8 for IndTestConditionalGaussianLrt; see the calibration notes below.Motivation (changes from the pre-2026-8 test computation, which differenced two
getLikelihood(int, int[])calls): getLikelihood prunes cells with fewer than minSampleSizePerCell rows and renormalizes the multinomial over the surviving rows, PER MODEL. Since the larger model partitions rows more finely than the smaller one, the two models could be fit on different row supports with differently renormalized likelihoods, so their difference was not a nested LRT: whenever pruning fired (rare cells, or the discretize path multiplying cell counts), the statistic picked up an O(droppedRows) term and the test rejected true nulls at far above nominal rates (harness: 100% rejection regimes at n = 200-1000). Additionally, dof counted all f(A) category combinations including empty and pruned cells, and the covariance used the unbiased (n-1) estimator rather than the MLE, neither of which cancels across partitions of different sizes.This method instead (1) determines eligibility ONCE, on the larger model's CONDITIONING partition (its discrete conditioning set after the discretize swap; the target joins the eligibility partition only in the estimability-forced discretize == false discrete-target case, since selecting rows on target-including cells truncates the joint and breaks a true null, while selecting on conditioning cells does not), keeping cells with at least max(minSampleSizePerCell, kMax + 1) rows, where kMax is the largest continuous dimension fit by either model; (2) evaluates all four joints on exactly those common rows with no further pruning; (3) counts dof over OBSERVED (nonempty) cells of each model's partition of the common rows; and (4) uses the MLE covariance inside the per-cell Gaussian likelihoods.
- Parameters:
i- The index of the target variable.parents0- The indices of the smaller model's conditioning variables.parents1- The indices of the larger model's conditioning variables (superset of parents0).- Returns:
- lik and dof differences (larger minus smaller conditional model) on the common support.
-
getLikelihoodRatio
public ConditionalGaussianLikelihood.Ret getLikelihoodRatio(int i, int[] parents0, int[] parents1, List<Integer> rows) AsgetLikelihoodRatio(int, int[], int[]), but evaluated over exactly the given rows, passed explicitly so that concurrent callers (the parallelized Markov checker, parallel constraint-based search) do not need to mutate shared state viasetRows(List). Added 2026-8-12.- Parameters:
i- The index of the target variable.parents0- The indices of the parents of the smaller (null) model.parents1- The indices of the parents of the larger model.rows- The rows over which to evaluate.- Returns:
- lik and dof differences on the common support of the given rows.
-
setDiscretize
public void setDiscretize(boolean discretize) Sets whether to discretize child variables to avoid integration. An optimization.- Parameters:
discretize- True, if so.- See Also:
-
setNumCategoriesToDiscretize
public void setNumCategoriesToDiscretize(int numCategoriesToDiscretize) Sets the number of categories to use to discretize child variables to avoid integration- Parameters:
numCategoriesToDiscretize- This number.- See Also:
-
setMinSampleSizePerCell
public void setMinSampleSizePerCell(int minSampleSizePerCell) Sets the minimum sample size per cell.- Parameters:
minSampleSizePerCell- The minimum sample size per cell.
-