use of edu.cmu.tetrad.algcomparison.independence.SemBicTest in project tetrad by cmu-phil.
the class TestKunMeasurementError method TestCycles_Data_fMRI_FASK.
public void TestCycles_Data_fMRI_FASK() {
Parameters parameters = new Parameters();
parameters.set("numRuns", 20);
parameters.set("penaltyDiscount", 1);
parameters.set("depth", -1);
parameters.set("determinismThreshold", .1);
parameters.set("verbose", true);
parameters.set("symmetricFirstStep", false);
parameters.set("faithfulnessAssumed", false);
parameters.set("maxDegree", 100);
Statistics statistics = new Statistics();
// statistics.add(new ParameterColumn("determinismThreshold"));
statistics.add(new AdjacencyPrecision());
statistics.add(new AdjacencyRecall());
statistics.add(new ArrowheadPrecision());
statistics.add(new ArrowheadRecall());
Simulations simulations = new Simulations();
// String dir = "/Users/user/Downloads/Simul1_T500";
String dir = "/Users/user/Downloads/Simul1_T2000";
// String dir = "/Users/user/Downloads/Simul2_T500";
// String dir = "/Users/user/Downloads/Simul2_T2000";
simulations.add(new LoadContinuousDataAndSingleGraphKun(dir, "Cov_X"));
simulations.add(new LoadContinuousDataAndSingleGraphKun(dir, "Cov_tilde"));
simulations.add(new LoadContinuousDataAndSingleGraphKun(dir, "Cov_tilde_hat"));
//
Algorithms algorithms = new Algorithms();
IndependenceWrapper test = new SemBicTest();
ScoreWrapper score = new SemBicScore();
algorithms.add(new Pc(test));
algorithms.add(new Fges(score));
algorithms.add(new Pcd());
algorithms.add(new FgesD());
Comparison comparison = new Comparison();
comparison.setShowAlgorithmIndices(true);
comparison.setShowSimulationIndices(true);
comparison.setSortByUtility(false);
comparison.setShowUtilities(false);
comparison.setParallelized(false);
comparison.setSaveGraphs(false);
comparison.setTabDelimitedTables(false);
comparison.compareFromSimulations("comparison", simulations, algorithms, statistics, parameters);
}
use of edu.cmu.tetrad.algcomparison.independence.SemBicTest in project tetrad by cmu-phil.
the class TestFges method test9.
public void test9() {
Parameters parameters = new Parameters();
parameters.set("numMeasures", 50);
parameters.set("numLatents", 0);
parameters.set("avgDegree", 2);
parameters.set("maxDegree", 20);
parameters.set("maxIndegree", 20);
parameters.set("maxOutdegree", 20);
parameters.set("connected", false);
parameters.set("coefLow", 0.2);
parameters.set("coefHigh", 0.9);
parameters.set("varLow", 1);
parameters.set("varHigh", 3);
parameters.set("verbose", false);
parameters.set("coefSymmetric", true);
parameters.set("numRuns", 1);
parameters.set("percentDiscrete", 0);
parameters.set("numCategories", 3);
parameters.set("differentGraphs", true);
parameters.set("sampleSize", 500);
parameters.set("intervalBetweenShocks", 10);
parameters.set("intervalBetweenRecordings", 10);
parameters.set("fisherEpsilon", 0.001);
parameters.set("randomizeColumns", true);
RandomGraph graph = new RandomForward();
LinearFisherModel sim = new LinearFisherModel(graph);
sim.createData(parameters);
Graph previous = null;
int prevDiff = Integer.MAX_VALUE;
// for (int l = 7; l >= 1; l--) {
for (int i = 2; i <= 20; i++) {
parameters.set("penaltyDiscount", i / (double) 10);
// parameters.set("alpha", Double.parseDouble("1E-" + l));
// ScoreWrapper score = new edu.cmu.tetrad.algcomparison.score.SemBicScore();
// Algorithm alg = new edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.Fges(score);
IndependenceWrapper test = new SemBicTest();
// IndependenceWrapper test = new FisherZ();
Algorithm alg = new edu.cmu.tetrad.algcomparison.algorithm.oracle.pattern.Cpc(test);
Graph out = alg.search(sim.getDataModel(0), parameters);
// Graph out = GraphUtils.undirectedGraph(alg.search(sim.getDataModel(0), parameters));
Set<Edge> edges1 = out.getEdges();
int numEdges = edges1.size();
if (previous != null) {
Set<Edge> edges2 = previous.getEdges();
edges2.removeAll(edges1);
int diff = edges2.size();
//
System.out.println("Penalty discount =" + parameters.getDouble("penaltyDiscount") + " # edges = " + numEdges + " # additional = " + diff);
previous = out;
if (diff > prevDiff)
break;
prevDiff = diff;
} else {
previous = out;
}
}
Graph estGraph = previous;
Graph trueGraph = sim.getTrueGraph(0);
estGraph = GraphUtils.replaceNodes(estGraph, trueGraph.getNodes());
Statistic ap = new AdjacencyPrecision();
Statistic ar = new AdjacencyRecall();
Statistic ahp = new ArrowheadPrecision();
Statistic ahr = new ArrowheadRecall();
System.out.println("AP = " + ap.getValue(trueGraph, estGraph));
System.out.println("AR = " + ar.getValue(trueGraph, estGraph));
System.out.println("AHP = " + ahp.getValue(trueGraph, estGraph));
System.out.println("AHR = " + ahr.getValue(trueGraph, estGraph));
}
Aggregations