From 61088c3d48e5ac82b0e8d56abbdf51bc04800577 Mon Sep 17 00:00:00 2001 From: vbcwonderland Date: Fri, 24 May 2024 14:58:24 -0400 Subject: [PATCH 1/2] Non Gaussian DAG for Local Markov Blanket test case, confusion stats using LocalGraphConfusion --- .../edu/cmu/tetrad/test/TestCheckMarkov.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCheckMarkov.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCheckMarkov.java index e1bd120fd4..a0128086a8 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCheckMarkov.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCheckMarkov.java @@ -489,4 +489,36 @@ public void testGaussianCPDAGPrecisionRecallForLocalOnMarkovBlanket2() { System.out.println("Rejects size: " + rejects.size()); } + @Test + public void testNonGaussianDAGPrecisionRecallForLocalOnMarkovBlanket2() { + Graph trueGraph = RandomGraph.randomDag(10, 0, 10, 100, 100, 100, false); + System.out.println("Test True Graph: " + trueGraph); + System.out.println("Test True Graph size: " + trueGraph.getNodes().size()); + + SemPm pm = new SemPm(trueGraph); + + Parameters params = new Parameters(); + // Manually set non-Gaussian + params.set(Params.SIMULATION_ERROR_TYPE, 3); + params.set(Params.SIMULATION_PARAM1, 1); + + SemIm im = new SemIm(pm, params); + DataSet data = im.simulateData(1000, false); + edu.cmu.tetrad.search.score.SemBicScore score = new SemBicScore(data, false); + score.setPenaltyDiscount(2); + Graph estimatedCpdag = new PermutationSearch(new Boss(score)).search(); + System.out.println("Test Estimated CPDAG Graph: " + estimatedCpdag); + System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + + IndependenceTest fisherZTest = new IndTestFisherZ(data, 0.05); + MarkovCheck markovCheck = new MarkovCheck(estimatedCpdag, fisherZTest, ConditioningSetType.MARKOV_BLANKET); + // ADTest pass/fail threshold default to be 0.05. shuffleThreshold default to be 0.5 + // List> accepts_rejects = markovCheck.getAndersonDarlingTestAcceptsRejectsNodesForAllNodes2(fisherZTest, estimatedCpdag, 0.05, 0.3); + List> accepts_rejects = markovCheck.getAndersonDarlingTestAcceptsRejectsNodesForAllNodesPlotData2(fisherZTest, estimatedCpdag, trueGraph, 0.05, 0.3); + List accepts = accepts_rejects.get(0); + List rejects = accepts_rejects.get(1); + System.out.println("Accepts size: " + accepts.size()); + System.out.println("Rejects size: " + rejects.size()); + } + } From 11e3123d7644fe110b911501ebf0c11c5cf83208 Mon Sep 17 00:00:00 2001 From: vbcwonderland Date: Fri, 24 May 2024 15:02:10 -0400 Subject: [PATCH 2/2] Non Gaussian CPDAG for Local Markov Blanket test case, confusion stats using LocalGraphConfusion --- .../edu/cmu/tetrad/test/TestCheckMarkov.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCheckMarkov.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCheckMarkov.java index a0128086a8..040b0fac5f 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCheckMarkov.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCheckMarkov.java @@ -521,4 +521,37 @@ public void testNonGaussianDAGPrecisionRecallForLocalOnMarkovBlanket2() { System.out.println("Rejects size: " + rejects.size()); } + @Test + public void testNonGaussianCPDAGPrecisionRecallForLocalOnMarkovBlanket2() { + Graph trueGraph = RandomGraph.randomDag(10, 0, 10, 100, 100, 100, false); + // The completed partially directed acyclic graph (CPDAG) for the given DAG. + Graph trueGraphCPDAG = GraphTransforms.dagToCpdag(trueGraph); + System.out.println("Test True Graph: " + trueGraph); + System.out.println("Test True Graph CPDAG: " + trueGraphCPDAG); + + SemPm pm = new SemPm(trueGraph); + + Parameters params = new Parameters(); + // Manually set non-Gaussian + params.set(Params.SIMULATION_ERROR_TYPE, 3); + params.set(Params.SIMULATION_PARAM1, 1); + + SemIm im = new SemIm(pm, params); + DataSet data = im.simulateData(1000, false); + edu.cmu.tetrad.search.score.SemBicScore score = new SemBicScore(data, false); + score.setPenaltyDiscount(2); + Graph estimatedCpdag = new PermutationSearch(new Boss(score)).search(); + System.out.println("Test Estimated CPDAG Graph: " + estimatedCpdag); + System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + + IndependenceTest fisherZTest = new IndTestFisherZ(data, 0.05); + MarkovCheck markovCheck = new MarkovCheck(estimatedCpdag, fisherZTest, ConditioningSetType.MARKOV_BLANKET); + // ADTest pass/fail threshold default to be 0.05. shuffleThreshold default to be 0.5 + // List> accepts_rejects = markovCheck.getAndersonDarlingTestAcceptsRejectsNodesForAllNodes2(fisherZTest, estimatedCpdag, 0.05, 0.5); + List> accepts_rejects = markovCheck.getAndersonDarlingTestAcceptsRejectsNodesForAllNodesPlotData2(fisherZTest, estimatedCpdag, trueGraph, 0.05, 0.3); + List accepts = accepts_rejects.get(0); + List rejects = accepts_rejects.get(1); + System.out.println("Accepts size: " + accepts.size()); + System.out.println("Rejects size: " + rejects.size()); + } }