use of edu.cmu.tetrad.data.ContinuousVariable in project tetrad by cmu-phil.
the class TestDagScorer method test1.
@Test
public void test1() {
RandomUtil.getInstance().setSeed(492839483L);
List<Node> nodes = new ArrayList<>();
for (int i = 0; i < 10; i++) {
nodes.add(new ContinuousVariable("X" + (i + 1)));
}
Graph dag = new Dag(GraphUtils.randomGraph(nodes, 0, 10, 30, 15, 15, false));
SemPm pm = new SemPm(dag);
SemIm im = new SemIm(pm);
DataSet data = im.simulateData(1000, false);
GraphUtils.replaceNodes(dag, data.getVariables());
SemEstimator est = new SemEstimator(data, pm);
SemIm estSem = est.estimate();
double fml = estSem.getScore();
assertEquals(0.0369, fml, 0.001);
dag = GraphUtils.replaceNodes(dag, data.getVariables());
Scorer scorer = new DagScorer(data);
double _fml = scorer.score(dag);
assertEquals(0.0358, _fml, 0.001);
double bicScore = scorer.getBicScore();
assertEquals(-205, bicScore, 1);
int dof = scorer.getDof();
assertEquals(35, dof);
int numFreeParams = scorer.getNumFreeParams();
assertEquals(20, numFreeParams);
}
Aggregations