use of edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest in project tetrad by cmu-phil.
the class TestGeneralBootstrapTest method testFCIc.
@Test
public void testFCIc() {
int penaltyDiscount = 2;
int depth = 3;
int maxPathLength = -1;
int numVars = 20;
int edgesPerNode = 2;
int numLatentConfounders = 2;
int numCases = 50;
int numBootstrapSamples = 5;
boolean verbose = true;
Graph dag = makeContinuousDAG(numVars, numLatentConfounders, edgesPerNode);
DagToPag dagToPag = new DagToPag(dag);
Graph truePag = dagToPag.convert();
System.out.println("Truth PAG_of_the_true_DAG Graph:");
System.out.println(truePag.toString());
int[] causalOrdering = new int[numVars];
for (int i = 0; i < numVars; i++) {
causalOrdering[i] = i;
}
LargeScaleSimulation simulator = new LargeScaleSimulation(dag, dag.getNodes(), causalOrdering);
DataSet data = simulator.simulateDataFisher(numCases);
Parameters parameters = new Parameters();
parameters.set("penaltyDiscount", penaltyDiscount);
parameters.set("depth", depth);
parameters.set("maxPathLength", maxPathLength);
parameters.set("numPatternsToStore", 0);
parameters.set("verbose", verbose);
IndependenceWrapper test = new FisherZ();
Fci algorithm = new Fci(test);
GeneralBootstrapTest bootstrapTest = new GeneralBootstrapTest(data, algorithm, numBootstrapSamples);
bootstrapTest.setVerbose(verbose);
bootstrapTest.setParameters(parameters);
bootstrapTest.setEdgeEnsemble(BootstrapEdgeEnsemble.Preserved);
// bootstrapTest.setParallelMode(false);
Graph resultGraph = bootstrapTest.search();
System.out.println("Estimated PAG_of_the_true_DAG Graph:");
System.out.println(resultGraph.toString());
// Adjacency Confusion Matrix
int[][] adjAr = GeneralBootstrapTest.getAdjConfusionMatrix(truePag, resultGraph);
printAdjConfusionMatrix(adjAr);
// Edge Type Confusion Matrix
int[][] edgeAr = GeneralBootstrapTest.getEdgeTypeConfusionMatrix(truePag, resultGraph);
printEdgeTypeConfusionMatrix(edgeAr);
}
use of edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest in project tetrad by cmu-phil.
the class TestGeneralBootstrapTest method testGFCIc.
@Test
public void testGFCIc() {
int penaltyDiscount = 2;
boolean faithfulnessAssumed = false;
int maxDegree = -1;
int numVars = 20;
int edgesPerNode = 2;
int numLatentConfounders = 2;
int numCases = 50;
int numBootstrapSamples = 5;
boolean verbose = true;
Graph dag = makeContinuousDAG(numVars, numLatentConfounders, edgesPerNode);
DagToPag dagToPag = new DagToPag(dag);
Graph truePag = dagToPag.convert();
System.out.println("Truth PAG_of_the_true_DAG Graph:");
System.out.println(truePag.toString());
int[] causalOrdering = new int[numVars];
for (int i = 0; i < numVars; i++) {
causalOrdering[i] = i;
}
LargeScaleSimulation simulator = new LargeScaleSimulation(dag, dag.getNodes(), causalOrdering);
DataSet data = simulator.simulateDataFisher(numCases);
Parameters parameters = new Parameters();
parameters.set("penaltyDiscount", penaltyDiscount);
parameters.set("faithfulnessAssumed", faithfulnessAssumed);
parameters.set("maxDegree", maxDegree);
parameters.set("numPatternsToStore", 0);
parameters.set("verbose", verbose);
ScoreWrapper score = new SemBicScore();
IndependenceWrapper test = new FisherZ();
Algorithm algorithm = new Gfci(test, score);
GeneralBootstrapTest bootstrapTest = new GeneralBootstrapTest(data, algorithm, numBootstrapSamples);
bootstrapTest.setVerbose(verbose);
bootstrapTest.setParameters(parameters);
bootstrapTest.setEdgeEnsemble(BootstrapEdgeEnsemble.Highest);
Graph resultGraph = bootstrapTest.search();
System.out.println("Estimated PAG_of_the_true_DAG Graph:");
System.out.println(resultGraph.toString());
// Adjacency Confusion Matrix
int[][] adjAr = GeneralBootstrapTest.getAdjConfusionMatrix(truePag, resultGraph);
printAdjConfusionMatrix(adjAr);
// Edge Type Confusion Matrix
int[][] edgeAr = GeneralBootstrapTest.getEdgeTypeConfusionMatrix(truePag, resultGraph);
printEdgeTypeConfusionMatrix(edgeAr);
}
Aggregations