Search in sources :

Example 56 with Node

use of edu.cmu.tetrad.graph.Node in project tetrad by cmu-phil.

the class FciOrientT method addColliders.

private void addColliders(Graph graph, final SepsetProducer sepsetProducer, IKnowledge knowledge) {
    List<Triple> colliders = findCollidersUsingSepsets(sepsetProducer, graph, verbose);
    for (Triple collider : colliders) {
        Node a = collider.getX();
        Node b = collider.getY();
        Node c = collider.getZ();
        if (!(isArrowpointAllowed(a, b, graph) && isArrowpointAllowed(c, b, graph))) {
            continue;
        }
        graph.setEndpoint(a, b, Endpoint.ARROW);
        graph.setEndpoint(c, b, Endpoint.ARROW);
    }
}
Also used : Triple(edu.cmu.tetrad.graph.Triple) Node(edu.cmu.tetrad.graph.Node)

Example 57 with Node

use of edu.cmu.tetrad.graph.Node in project tetrad by cmu-phil.

the class IndTestDirichletScore method indTestSubset.

// ==========================PUBLIC METHODS=============================//
/**
 * Creates a new independence test instance for a subset of the variables.
 */
public IndependenceTest indTestSubset(List<Node> vars) {
    if (vars.isEmpty()) {
        throw new IllegalArgumentException("Subset may not be empty.");
    }
    for (Node var : vars) {
        if (!variables.contains(var)) {
            throw new IllegalArgumentException("All vars must be original vars");
        }
    }
    int[] indices = new int[vars.size()];
    for (int i = 0; i < indices.length; i++) {
        indices[i] = indexMap.get(vars.get(i));
    }
    DataSet newDataSet = dataSet.subsetColumns(indices);
    return new IndTestDirichletScore(newDataSet, getSamplePrior(), getStructurePrior());
}
Also used : DataSet(edu.cmu.tetrad.data.DataSet) Node(edu.cmu.tetrad.graph.Node)

Example 58 with Node

use of edu.cmu.tetrad.graph.Node in project tetrad by cmu-phil.

the class IndTestDirichletScore method getVariableNames.

/**
 * @return the list of variable varNames.
 */
public List<String> getVariableNames() {
    List<Node> variables = getVariables();
    List<String> variableNames = new ArrayList<>();
    for (Node variable1 : variables) {
        variableNames.add(variable1.getName());
    }
    return variableNames;
}
Also used : Node(edu.cmu.tetrad.graph.Node) ArrayList(java.util.ArrayList)

Example 59 with Node

use of edu.cmu.tetrad.graph.Node in project tetrad by cmu-phil.

the class IndTestFisherZ method getVariableNames.

/**
 * @return the list of variable varNames.
 */
public List<String> getVariableNames() {
    List<Node> variables = getVariables();
    List<String> variableNames = new ArrayList<>();
    for (Node variable1 : variables) {
        variableNames.add(variable1.getName());
    }
    return variableNames;
}
Also used : Node(edu.cmu.tetrad.graph.Node)

Example 60 with Node

use of edu.cmu.tetrad.graph.Node in project tetrad by cmu-phil.

the class IndTestFisherZ method indTestSubset.

// ==========================PUBLIC METHODS=============================//
/**
 * Creates a new independence test instance for a subset of the variables.
 */
public IndependenceTest indTestSubset(List<Node> vars) {
    if (vars.isEmpty()) {
        throw new IllegalArgumentException("Subset may not be empty.");
    }
    for (Node var : vars) {
        if (!variables.contains(var)) {
            throw new IllegalArgumentException("All vars must be original vars");
        }
    }
    int[] indices = new int[vars.size()];
    for (int i = 0; i < indices.length; i++) {
        indices[i] = indexMap.get(vars.get(i));
    }
    ICovarianceMatrix newCovMatrix = covMatrix.getSubmatrix(indices);
    double alphaNew = getAlpha();
    return new IndTestFisherZ(newCovMatrix, alphaNew);
}
Also used : Node(edu.cmu.tetrad.graph.Node)

Aggregations

Node (edu.cmu.tetrad.graph.Node)674 ArrayList (java.util.ArrayList)129 Graph (edu.cmu.tetrad.graph.Graph)106 GraphNode (edu.cmu.tetrad.graph.GraphNode)64 DataSet (edu.cmu.tetrad.data.DataSet)59 LinkedList (java.util.LinkedList)55 ContinuousVariable (edu.cmu.tetrad.data.ContinuousVariable)48 Test (org.junit.Test)48 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)46 List (java.util.List)45 Dag (edu.cmu.tetrad.graph.Dag)41 TetradMatrix (edu.cmu.tetrad.util.TetradMatrix)41 DiscreteVariable (edu.cmu.tetrad.data.DiscreteVariable)40 ChoiceGenerator (edu.cmu.tetrad.util.ChoiceGenerator)37 Endpoint (edu.cmu.tetrad.graph.Endpoint)29 DisplayNode (edu.cmu.tetradapp.workbench.DisplayNode)26 ColtDataSet (edu.cmu.tetrad.data.ColtDataSet)25 Edge (edu.cmu.tetrad.graph.Edge)23 SemIm (edu.cmu.tetrad.sem.SemIm)19 DepthChoiceGenerator (edu.cmu.tetrad.util.DepthChoiceGenerator)19