Search in sources :

Example 21 with LargeScaleSimulation

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);
}
Also used : ArrayList(java.util.ArrayList) LargeScaleSimulation(edu.cmu.tetrad.sem.LargeScaleSimulation) Test(org.junit.Test)

Aggregations

LargeScaleSimulation (edu.cmu.tetrad.sem.LargeScaleSimulation)21 Graph (edu.cmu.tetrad.graph.Graph)6 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)5 BayesPm (edu.cmu.tetrad.bayes.BayesPm)4 MlBayesIm (edu.cmu.tetrad.bayes.MlBayesIm)4 DataSet (edu.cmu.tetrad.data.DataSet)4 Node (edu.cmu.tetrad.graph.Node)3 Parameters (edu.cmu.tetrad.util.Parameters)3 GeneralBootstrapTest (edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest)3 Algorithm (edu.cmu.tetrad.algcomparison.algorithm.Algorithm)2 FisherZ (edu.cmu.tetrad.algcomparison.independence.FisherZ)2 IndependenceWrapper (edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper)2 ScoreWrapper (edu.cmu.tetrad.algcomparison.score.ScoreWrapper)2 SemBicScore (edu.cmu.tetrad.algcomparison.score.SemBicScore)2 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)2 DagToPag (edu.cmu.tetrad.search.DagToPag)2 List (java.util.List)2 Fci (edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.Fci)1 Gfci (edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.Gfci)1