Search in sources :

Example 36 with BayesIm

use of edu.cmu.tetrad.bayes.BayesIm in project tetrad by cmu-phil.

the class TestBayesBicScorer method testPValue.

@Test
public void testPValue() {
    RandomUtil.getInstance().setSeed(492834924L);
    // Graph graph = GraphConverter.convert("X1,X2,X4,X4,X5,X6,X7,X8");
    Graph graph = GraphConverter.convert("X1-->X2,X2-->X3,X3-->X6,X6-->X7");
    // Graph graph2 = GraphConverter.convert("X1,X2,X3,X7-->X6,X9,X10,X11,X12");
    int numCategories = 8;
    BayesPm pm = new BayesPm(graph, numCategories, numCategories);
    BayesIm im = new MlBayesIm(pm, MlBayesIm.RANDOM);
    DataSet data = im.simulateData(1000, false);
    BayesProperties scorer = new BayesProperties(data);
    double lik = scorer.getLikelihoodRatioP(graph);
    assertEquals(1, lik, 0.001);
}
Also used : BayesProperties(edu.cmu.tetrad.bayes.BayesProperties) Graph(edu.cmu.tetrad.graph.Graph) MlBayesIm(edu.cmu.tetrad.bayes.MlBayesIm) DataSet(edu.cmu.tetrad.data.DataSet) BayesIm(edu.cmu.tetrad.bayes.BayesIm) MlBayesIm(edu.cmu.tetrad.bayes.MlBayesIm) BayesPm(edu.cmu.tetrad.bayes.BayesPm) Test(org.junit.Test)

Aggregations

BayesIm (edu.cmu.tetrad.bayes.BayesIm)36 MlBayesIm (edu.cmu.tetrad.bayes.MlBayesIm)21 BayesPm (edu.cmu.tetrad.bayes.BayesPm)18 Test (org.junit.Test)14 Graph (edu.cmu.tetrad.graph.Graph)7 Node (edu.cmu.tetrad.graph.Node)7 DataSet (edu.cmu.tetrad.data.DataSet)6 Dag (edu.cmu.tetrad.graph.Dag)5 Algorithm (edu.cmu.tetrad.algcomparison.algorithm.Algorithm)3 GraphNode (edu.cmu.tetrad.graph.GraphNode)3 Parameters (edu.cmu.tetrad.util.Parameters)3 GeneralBootstrapTest (edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest)3 File (java.io.File)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Element (nu.xom.Element)3 RandomGraph (edu.cmu.tetrad.algcomparison.graph.RandomGraph)2 ChiSquare (edu.cmu.tetrad.algcomparison.independence.ChiSquare)2 IndependenceWrapper (edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper)2 BdeuScore (edu.cmu.tetrad.algcomparison.score.BdeuScore)2