Search in sources :

Example 1 with Ricf

use of edu.cmu.tetrad.sem.Ricf in project tetrad by cmu-phil.

the class TestRicf method testCliques.

@Test
public void testCliques() {
    Graph graph = new EdgeListGraph();
    ContinuousVariable x0 = new ContinuousVariable("X0");
    ContinuousVariable x1 = new ContinuousVariable("X1");
    ContinuousVariable x2 = new ContinuousVariable("X2");
    ContinuousVariable x3 = new ContinuousVariable("X3");
    ContinuousVariable x4 = new ContinuousVariable("X4");
    ContinuousVariable x5 = new ContinuousVariable("X5");
    graph.addNode(x0);
    graph.addNode(x1);
    graph.addNode(x2);
    graph.addNode(x3);
    graph.addNode(x4);
    graph.addNode(x5);
    graph.addUndirectedEdge(x0, x1);
    graph.addUndirectedEdge(x0, x2);
    graph.addUndirectedEdge(x0, x3);
    graph.addUndirectedEdge(x1, x2);
    graph.addUndirectedEdge(x1, x3);
    graph.addUndirectedEdge(x1, x4);
    graph.addUndirectedEdge(x2, x4);
    graph.addUndirectedEdge(x5, x0);
    graph.addUndirectedEdge(x5, x1);
    graph.addUndirectedEdge(x5, x2);
    new Ricf().cliques(graph);
}
Also used : Ricf(edu.cmu.tetrad.sem.Ricf) Test(org.junit.Test)

Example 2 with Ricf

use of edu.cmu.tetrad.sem.Ricf in project tetrad by cmu-phil.

the class TestRicf method test3.

// File not found.
@Ignore
public void test3() {
    try {
        DataReader reader = new DataReader();
        final File datapath = new File("/Users/josephramsey/Downloads/data6.txt");
        DataSet dataSet = reader.parseTabular(datapath);
        Graph mag = GraphUtils.loadGraphTxt(new File("/Users/josephramsey/Downloads/graph3.txt"));
        ICovarianceMatrix cov = new CovarianceMatrix(dataSet);
        new Ricf().ricf(new SemGraph(mag), cov, 0.001);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : IOException(java.io.IOException) Ricf(edu.cmu.tetrad.sem.Ricf) File(java.io.File) Ignore(org.junit.Ignore)

Example 3 with Ricf

use of edu.cmu.tetrad.sem.Ricf in project tetrad by cmu-phil.

the class TestRicf method testCliques2.

@Test
public void testCliques2() {
    List<Node> nodes = new ArrayList<>();
    for (int i = 0; i < 8; i++) {
        nodes.add(new ContinuousVariable("X" + (i + 1)));
    }
    Graph graph = new Dag(GraphUtils.randomGraph(nodes, 0, 20, 5, 5, 5, false));
    new Ricf().cliques(graph);
}
Also used : ArrayList(java.util.ArrayList) Ricf(edu.cmu.tetrad.sem.Ricf) Test(org.junit.Test)

Example 4 with Ricf

use of edu.cmu.tetrad.sem.Ricf in project tetrad by cmu-phil.

the class TestRicf method testCliques3.

/**
 * Whittaker p. 59.
 */
@Test
public void testCliques3() {
    Graph graph = new EdgeListGraph();
    ContinuousVariable x1 = new ContinuousVariable("X1");
    ContinuousVariable x2 = new ContinuousVariable("X2");
    ContinuousVariable x3 = new ContinuousVariable("X3");
    ContinuousVariable x4 = new ContinuousVariable("X4");
    ContinuousVariable x5 = new ContinuousVariable("X5");
    ContinuousVariable x6 = new ContinuousVariable("X6");
    ContinuousVariable x7 = new ContinuousVariable("X7");
    graph.addNode(x1);
    graph.addNode(x2);
    graph.addNode(x3);
    graph.addNode(x4);
    graph.addNode(x5);
    graph.addNode(x6);
    graph.addNode(x7);
    graph.addUndirectedEdge(x1, x2);
    graph.addUndirectedEdge(x1, x4);
    graph.addUndirectedEdge(x2, x3);
    graph.addUndirectedEdge(x2, x5);
    graph.addUndirectedEdge(x3, x5);
    graph.addUndirectedEdge(x4, x5);
    graph.addUndirectedEdge(x5, x6);
    new Ricf().cliques(graph);
}
Also used : Ricf(edu.cmu.tetrad.sem.Ricf) Test(org.junit.Test)

Example 5 with Ricf

use of edu.cmu.tetrad.sem.Ricf in project tetrad by cmu-phil.

the class TestRicf method test2.

@Test
public void test2() {
    List<Node> nodes = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        nodes.add(new ContinuousVariable("X" + (i + 1)));
    }
    Graph graph = new Dag(GraphUtils.randomGraph(nodes, 0, 10, 30, 15, 15, false));
    SemPm pm = new SemPm(graph);
    SemIm im = new SemIm(pm);
    DataSet data = im.simulateData(1000, false);
    CovarianceMatrix cov = new CovarianceMatrix(data);
    Ricf.RicfResult result = new Ricf().ricf(new SemGraph(graph), cov, 0.001);
    result.getBhat();
}
Also used : ArrayList(java.util.ArrayList) SemPm(edu.cmu.tetrad.sem.SemPm) Ricf(edu.cmu.tetrad.sem.Ricf) SemIm(edu.cmu.tetrad.sem.SemIm) Test(org.junit.Test)

Aggregations

Ricf (edu.cmu.tetrad.sem.Ricf)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)3 SemIm (edu.cmu.tetrad.sem.SemIm)2 SemPm (edu.cmu.tetrad.sem.SemPm)2 TetradMatrix (edu.cmu.tetrad.util.TetradMatrix)1 File (java.io.File)1 IOException (java.io.IOException)1 Ignore (org.junit.Ignore)1