Search in sources :

Example 1 with MGM

use of edu.pitt.csb.mgm.MGM in project tetrad by cmu-phil.

the class Mgm method search.

@Override
public Graph search(DataModel ds, Parameters parameters) {
    // Notify the user that you need at least one continuous and one discrete variable to run MGM
    List<Node> variables = ds.getVariables();
    boolean hasContinuous = false;
    boolean hasDiscrete = false;
    for (Node node : variables) {
        if (node instanceof ContinuousVariable) {
            hasContinuous = true;
        }
        if (node instanceof DiscreteVariable) {
            hasDiscrete = true;
        }
    }
    if (!hasContinuous || !hasDiscrete) {
        throw new IllegalArgumentException("You need at least one continuous and one discrete variable to run MGM.");
    }
    if (parameters.getInt("bootstrapSampleSize") < 1) {
        DataSet _ds = DataUtils.getMixedDataSet(ds);
        double mgmParam1 = parameters.getDouble("mgmParam1");
        double mgmParam2 = parameters.getDouble("mgmParam2");
        double mgmParam3 = parameters.getDouble("mgmParam3");
        double[] lambda = { mgmParam1, mgmParam2, mgmParam3 };
        MGM m = new MGM(_ds, lambda);
        return m.search();
    } else {
        Mgm algorithm = new Mgm();
        DataSet data = (DataSet) ds;
        GeneralBootstrapTest search = new GeneralBootstrapTest(data, algorithm, parameters.getInt("bootstrapSampleSize"));
        BootstrapEdgeEnsemble edgeEnsemble = BootstrapEdgeEnsemble.Highest;
        switch(parameters.getInt("bootstrapEnsemble", 1)) {
            case 0:
                edgeEnsemble = BootstrapEdgeEnsemble.Preserved;
                break;
            case 1:
                edgeEnsemble = BootstrapEdgeEnsemble.Highest;
                break;
            case 2:
                edgeEnsemble = BootstrapEdgeEnsemble.Majority;
        }
        search.setEdgeEnsemble(edgeEnsemble);
        search.setParameters(parameters);
        search.setVerbose(parameters.getBoolean("verbose"));
        return search.search();
    }
}
Also used : GeneralBootstrapTest(edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest) BootstrapEdgeEnsemble(edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble) DataSet(edu.cmu.tetrad.data.DataSet) Node(edu.cmu.tetrad.graph.Node) ContinuousVariable(edu.cmu.tetrad.data.ContinuousVariable) DiscreteVariable(edu.cmu.tetrad.data.DiscreteVariable) MGM(edu.pitt.csb.mgm.MGM)

Example 2 with MGM

use of edu.pitt.csb.mgm.MGM in project tetrad by cmu-phil.

the class TestFges method searchMGMFges.

public Graph searchMGMFges(DataSet ds, double penalty) {
    MGM m = new MGM(ds, new double[] { 0.1, 0.1, 0.1 });
    // m.setVerbose(this.verbose);
    Graph gm = m.search();
    DataSet dataSet = MixedUtils.makeContinuousData(ds);
    SemBicScore score = new SemBicScore(new CovarianceMatrixOnTheFly(dataSet));
    score.setPenaltyDiscount(penalty);
    Fges fg = new Fges(score);
    fg.setBoundGraph(gm);
    fg.setVerbose(false);
    return fg.search();
}
Also used : MGM(edu.pitt.csb.mgm.MGM) RandomGraph(edu.cmu.tetrad.algcomparison.graph.RandomGraph) Fges(edu.cmu.tetrad.search.Fges) SemBicScore(edu.cmu.tetrad.search.SemBicScore)

Aggregations

MGM (edu.pitt.csb.mgm.MGM)2 RandomGraph (edu.cmu.tetrad.algcomparison.graph.RandomGraph)1 ContinuousVariable (edu.cmu.tetrad.data.ContinuousVariable)1 DataSet (edu.cmu.tetrad.data.DataSet)1 DiscreteVariable (edu.cmu.tetrad.data.DiscreteVariable)1 Node (edu.cmu.tetrad.graph.Node)1 Fges (edu.cmu.tetrad.search.Fges)1 SemBicScore (edu.cmu.tetrad.search.SemBicScore)1 BootstrapEdgeEnsemble (edu.pitt.dbmi.algo.bootstrap.BootstrapEdgeEnsemble)1 GeneralBootstrapTest (edu.pitt.dbmi.algo.bootstrap.GeneralBootstrapTest)1