use of edu.cmu.tetrad.sem.SemIm in project tetrad by cmu-phil.
the class TestStandardizedSem method test5.
@Test
public void test5() {
RandomUtil.getInstance().setSeed(582374923L);
SemGraph graph = new SemGraph();
graph.setShowErrorTerms(true);
Node x1 = new ContinuousVariable("X1");
Node x2 = new ContinuousVariable("X2");
Node x3 = new ContinuousVariable("X3");
graph.addNode(x1);
graph.addNode(x2);
graph.addNode(x3);
graph.setShowErrorTerms(true);
Node ex1 = graph.getExogenous(x1);
Node ex2 = graph.getExogenous(x2);
Node ex3 = graph.getExogenous(x3);
graph.addDirectedEdge(x1, x3);
graph.addDirectedEdge(x2, x3);
// graph.addDirectedEdge(x1, x2);
// graph.addBidirectedEdge(ex1, ex2);
SemPm pm = new SemPm(graph);
SemIm im = new SemIm(pm);
DataSet dataSet = im.simulateDataRecursive(1000, false);
TetradMatrix _dataSet = dataSet.getDoubleData();
_dataSet = DataUtils.standardizeData(_dataSet);
DataSet dataSetStandardized = ColtDataSet.makeData(dataSet.getVariables(), _dataSet);
SemEstimator estimator = new SemEstimator(dataSetStandardized, im.getSemPm());
SemIm imStandardized = estimator.estimate();
StandardizedSemIm sem = new StandardizedSemIm(im);
// sem.setErrorCovariance(ex1, ex2, -.24);
assertTrue(isStandardized(sem));
}
use of edu.cmu.tetrad.sem.SemIm in project tetrad by cmu-phil.
the class TestStandardizedSem method test2.
@Test
public void test2() {
RandomUtil.getInstance().setSeed(5729384723L);
SemGraph graph = new SemGraph();
Node x1 = new ContinuousVariable("X1");
Node x2 = new ContinuousVariable("X2");
Node x3 = new ContinuousVariable("X3");
Node x4 = new ContinuousVariable("X4");
Node x5 = new ContinuousVariable("X5");
graph.addNode(x1);
graph.addNode(x2);
graph.addNode(x3);
graph.addNode(x4);
graph.addNode(x5);
graph.setShowErrorTerms(true);
graph.addDirectedEdge(x1, x2);
graph.addDirectedEdge(x2, x3);
graph.addDirectedEdge(x4, x3);
graph.addDirectedEdge(x2, x4);
graph.addDirectedEdge(x1, x4);
graph.addDirectedEdge(x5, x4);
SemPm pm = new SemPm(graph);
SemIm im = new SemIm(pm);
StandardizedSemIm sem = new StandardizedSemIm(im);
assertTrue(isStandardized(sem));
}
use of edu.cmu.tetrad.sem.SemIm in project tetrad by cmu-phil.
the class TestStandardizedSem method test6.
@Test
public void test6() {
// RandomUtil.getInstance().setSeed(582374923L);
SemGraph graph = new SemGraph();
graph.setShowErrorTerms(true);
Node x1 = new ContinuousVariable("X1");
Node x2 = new ContinuousVariable("X2");
Node x3 = new ContinuousVariable("X3");
graph.addNode(x1);
graph.addNode(x2);
graph.addNode(x3);
graph.setShowErrorTerms(true);
Node ex1 = graph.getExogenous(x1);
Node ex2 = graph.getExogenous(x2);
Node ex3 = graph.getExogenous(x3);
graph.addDirectedEdge(x1, x3);
graph.addDirectedEdge(x2, x3);
graph.addDirectedEdge(x1, x2);
graph.addBidirectedEdge(ex1, ex2);
// List<List<Node>> treks = DataGraphUtils.treksIncludingBidirected(graph, x1, x3);
//
// for (List<Node> trek : treks) {
// System.out.println(trek);
// }
SemPm pm = new SemPm(graph);
SemIm im = new SemIm(pm);
DataSet dataSet = im.simulateDataRecursive(1000, false);
TetradMatrix _dataSet = dataSet.getDoubleData();
_dataSet = DataUtils.standardizeData(_dataSet);
DataSet dataSetStandardized = ColtDataSet.makeData(dataSet.getVariables(), _dataSet);
SemEstimator estimator = new SemEstimator(dataSetStandardized, im.getSemPm());
SemIm imStandardized = estimator.estimate();
StandardizedSemIm sem = new StandardizedSemIm(im);
assertTrue(isStandardized(sem));
}
use of edu.cmu.tetrad.sem.SemIm in project tetrad by cmu-phil.
the class TestSemXml method testRoundtrip3.
public void testRoundtrip3() {
SemIm semIm = sampleSemIm1();
Element element = SemXmlRenderer.getElement(semIm);
SemXmlParser parser = new SemXmlParser();
SemIm semIm2 = parser.getSemIm(element);
}
use of edu.cmu.tetrad.sem.SemIm in project tetrad by cmu-phil.
the class TestSemXml method testRosemIm2undtrip.
public static void testRosemIm2undtrip() {
SemIm semIm = sampleSemIm1();
Element element = SemXmlRenderer.getElement(semIm);
SemXmlParser parser = new SemXmlParser();
SemIm semIm2 = parser.getSemIm(element);
}
Aggregations