use of edu.cmu.tetrad.sem.LargeScaleSimulation in project tetrad by cmu-phil.
the class TestGFci method testFromData.
@Test
public void testFromData() {
int numNodes = 20;
int numLatents = 5;
int numEdges = 20;
int sampleSize = 50;
List<Node> variables = new ArrayList<>();
for (int i = 0; i < numNodes; i++) {
variables.add(new ContinuousVariable("X" + (i + 1)));
}
Graph g = GraphUtils.randomGraphRandomForwardEdges(variables, numLatents, numEdges, 10, 10, 10, false, false);
LargeScaleSimulation semSimulator = new LargeScaleSimulation(g);
DataSet data = semSimulator.simulateDataFisher(sampleSize);
data = DataUtils.restrictToMeasured(data);
IndependenceTest test = new IndTestFisherZ(new CovarianceMatrixOnTheFly(data), 0.001);
SemBicScore score = new SemBicScore(new CovarianceMatrixOnTheFly(data));
score.setPenaltyDiscount(4);
GFci gFci = new GFci(test, score);
gFci.setFaithfulnessAssumed(true);
long start = System.currentTimeMillis();
gFci.search();
long stop = System.currentTimeMillis();
System.out.println("Elapsed " + (stop - start) + " ms");
DagToPag dagToPag = new DagToPag(g);
dagToPag.setVerbose(false);
}
Aggregations