use of edu.cmu.tetrad.data.CovarianceMatrixOnTheFly in project tetrad by cmu-phil.
the class TestSimulatedFmri method testClark2.
// @Test
public void testClark2() {
Node x = new ContinuousVariable("X");
Node y = new ContinuousVariable("Y");
Node z = new ContinuousVariable("Z");
Graph g = new EdgeListGraph();
g.addNode(x);
g.addNode(y);
g.addNode(z);
g.addDirectedEdge(x, y);
g.addDirectedEdge(x, z);
g.addDirectedEdge(y, z);
GeneralizedSemPm pm = new GeneralizedSemPm(g);
try {
pm.setNodeExpression(g.getNode("X"), "E_X");
pm.setNodeExpression(g.getNode("Y"), "0.4 * X + E_Y");
pm.setNodeExpression(g.getNode("Z"), "0.4 * X + 0.4 * Y + E_Z");
String error = "pow(Uniform(0, 1), 1.5)";
pm.setNodeExpression(pm.getErrorNode(g.getNode("X")), error);
pm.setNodeExpression(pm.getErrorNode(g.getNode("Y")), error);
pm.setNodeExpression(pm.getErrorNode(g.getNode("Z")), error);
} catch (ParseException e) {
System.out.println(e);
}
GeneralizedSemIm im = new GeneralizedSemIm(pm);
DataSet data = im.simulateData(1000, false);
edu.cmu.tetrad.search.SemBicScore score = new edu.cmu.tetrad.search.SemBicScore(new CovarianceMatrixOnTheFly(data, false));
Fask fask = new Fask(data, score);
fask.setPenaltyDiscount(1);
fask.setAlpha(0.5);
Graph out = fask.search();
System.out.println(out);
}
use of edu.cmu.tetrad.data.CovarianceMatrixOnTheFly in project tetrad by cmu-phil.
the class FasLofs method search.
// ======================================== PUBLIC METHODS ====================================//
/**
* Runs the search on the concatenated data, returning a graph, possibly cyclic, possibly with
* two-cycles. Runs the fast adjacency search (FAS, Spirtes et al., 2000) follows by a modification
* of the robust skew rule (Pairwise Likelihood Ratios for Estimation of Non-Gaussian Structural
* Equation Models, Smith and Hyvarinen), together with some heuristics for orienting two-cycles.
*
* @return the graph. Some of the edges may be undirected (though it shouldn't be many in most cases)
* and some of the adjacencies may be two-cycles.
*/
public Graph search() {
long start = System.currentTimeMillis();
SemBicScore score = new SemBicScore(new CovarianceMatrixOnTheFly(dataSet));
score.setPenaltyDiscount(penaltyDiscount);
IndependenceTest test = new IndTestScore(score, dataSet);
System.out.println("FAS");
FasStable fas = new FasStable(test);
fas.setDepth(getDepth());
fas.setVerbose(false);
fas.setKnowledge(knowledge);
Graph G0 = fas.search();
System.out.println("LOFS orientation, rule " + rule);
Lofs2 lofs2 = new Lofs2(G0, Collections.singletonList(dataSet));
lofs2.setRule(rule);
lofs2.setKnowledge(knowledge);
Graph graph = lofs2.orient();
System.out.println("Done");
long stop = System.currentTimeMillis();
this.elapsed = stop - start;
return graph;
}
Aggregations