Class MarkovCheckNullReference
Parametric-bootstrap null reference for the Markov check
A Markov check that fails under a strict independence test is ambiguous between two very
different situations: (a) the test is miscalibrated at this sample size and data scale,
so its p-values are non-uniform even when the implied independencies hold, and (b) the
model is genuinely inadequate, i.e., the graph implies independencies the data violates.
This class separates them experimentally: it fits a simulator to (data, DAG), simulates
numDraws datasets that satisfy the DAG's factorization by construction, runs the
identical Markov check on each, and reports where the real data's check statistic falls in that
null distribution.
Simulators
MarkovCheckNullReference.SimulatorType.TRAINED_DAG_GNM--TrainedDagSimulatorGNM: neural local mechanisms with bootstrapped noise, anchored to the observed dataset. The preferred null: it probes the test's behavior under realistic conditionals, so a real-data failure that the null draws do not reproduce is attributable to the graph/model, not the test.MarkovCheckNullReference.SimulatorType.LINEAR_SEM-- a linear-Gaussian SEM fitted bySemEstimator. A clean in-class null, useful as a test-calibration baseline: if the check fails even on these draws, suspect the test before the model.
Reading the result
MarkovCheckNullReference.Result.getEmpiricalP() is the fraction of null draws whose Anderson-Darling
uniformity p-value (over independence facts) is at or below the real data's value; its
resolution is 1/numDraws. Real fails while the GNM null passes: genuine graph/model inadequacy.
GNM null also fails: test miscalibration under realistic conditionals, or simulator leakage --
compare with the linear null to separate those. Null values clustered near 1: a broken
simulator (lost sampling variation), since under a healthy null the statistic should be roughly
uniform. This class reports statistics only; decisions about the model belong to the user.
Caveats
- The reference inherits the Markov check's one-sidedness: it certifies the implied independencies, not the dependencies missing edges fail to imply. It sharpens "fails Markov" into a diagnosis; it does not turn "passes Markov" into an endorsement.
- With bootstrapped (unstratified) residuals for continuous children, parent-dependent noise scale in the real data may not be fully reproduced in the null draws, so part of a real-data failure may reflect variance structure rather than graph structure.
- If the checked graph implies no independence facts, the Anderson-Darling statistics are undefined and the empirical p is reported as NaN.
- For
MarkovCheckNullReference.SimulatorType.LINEAR_SEM, draws use the sharedRandomUtilstream; the base seed is applied to it once before the draws (a global side effect).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThe real-data check statistics and the null distributions, with empirical p-values and component timings.static enumThe simulator used to generate null draws from the fitted (data, DAG) model. -
Method Summary
Modifier and TypeMethodDescriptioncompute(DataSet data, Graph graph, IndependenceWrapper testWrapper, Parameters parameters, ConditioningSetType conditioningSetType, MarkovCheckNullReference.SimulatorType simulator, int numDraws, int sampleSize, long baseSeed, TrainedDagSimulatorGNM.Params gnmParams) Convenience overload taking anIndependenceWrapperandParameters, matching how the Markov-check test is configured in algcomparison and in py-tetrad's TetradSearch.compute(DataSet data, Graph graph, Function<DataSet, IndependenceTest> testFactory, ConditioningSetType conditioningSetType, MarkovCheckNullReference.SimulatorType simulator, int numDraws, int sampleSize, long baseSeed, TrainedDagSimulatorGNM.Params gnmParams) Computes the null reference using a test factory.
-
Method Details
-
compute
public static MarkovCheckNullReference.Result compute(DataSet data, Graph graph, Function<DataSet, IndependenceTest> testFactory, ConditioningSetType conditioningSetType, MarkovCheckNullReference.SimulatorType simulator, int numDraws, int sampleSize, long baseSeed, TrainedDagSimulatorGNM.Params gnmParams) Computes the null reference using a test factory.- Parameters:
data- The observed dataset.graph- The graph whose Markov property is checked. A CPDAG is converted to a member DAG viaGraphTransforms.dagFromCpdag(Graph); the DAG actually checked is available from the result.testFactory- Creates the Markov-check independence test for a given dataset; must produce the same test configuration used on the real data.conditioningSetType- The conditioning-set type for the Markov check.simulator- The null-draw simulator.numDraws- The number of null draws (empirical-p resolution is 1/numDraws).sampleSize- Rows per simulated dataset; nonpositive means the size ofdata.baseSeed- Base seed; draw b uses seedbaseSeed + b(GNM), or the seed is applied once toRandomUtil(linear).gnmParams- Parameters for the GNM simulator; null means defaults. Ignored for the linear simulator.- Returns:
- The
MarkovCheckNullReference.Result.
-
compute
public static MarkovCheckNullReference.Result compute(DataSet data, Graph graph, IndependenceWrapper testWrapper, Parameters parameters, ConditioningSetType conditioningSetType, MarkovCheckNullReference.SimulatorType simulator, int numDraws, int sampleSize, long baseSeed, TrainedDagSimulatorGNM.Params gnmParams) Convenience overload taking anIndependenceWrapperandParameters, matching how the Markov-check test is configured in algcomparison and in py-tetrad's TetradSearch.- Parameters:
data- The observed dataset.graph- The graph whose Markov property is checked (see the primary overload for CPDAG handling).testWrapper- The independence-test wrapper for the Markov-check test.parameters- The parameters used to instantiate the test.conditioningSetType- The conditioning-set type for the Markov check.simulator- The null-draw simulator.numDraws- The number of null draws.sampleSize- Rows per simulated dataset; nonpositive means the size ofdata.baseSeed- Base seed for the draws.gnmParams- Parameters for the GNM simulator; null means defaults.- Returns:
- The
MarkovCheckNullReference.Result.
-