Search in sources :

Example 71 with Node

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

the class IndTestCramerT method getVariableNames.

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

Example 72 with Node

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

the class IndTestFisherZPercentIndependent 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 73 with Node

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

the class IndTestGSquare 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 74 with Node

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

the class IndTestGSquare method isIndependent.

/**
 * Determines whether variable x is independent of variable y given a list of conditioning varNames z.
 *
 * @param x the one variable being compared.
 * @param y the second variable being compared.
 * @param z the list of conditioning varNames.
 * @return true iff x _||_ y | z.
 */
public boolean isIndependent(Node x, Node y, List<Node> z) {
    if (x == null) {
        throw new NullPointerException();
    }
    if (y == null) {
        throw new NullPointerException();
    }
    if (z == null) {
        throw new NullPointerException();
    }
    for (Node node : z) {
        if (node == null) {
            throw new NullPointerException();
        }
    }
    // For testing x, y given z1,...,zn, set up an array of length
    // n + 2 containing the indices of these variables in order.
    int[] testIndices = new int[2 + z.size()];
    testIndices[0] = variables.indexOf(x);
    testIndices[1] = variables.indexOf(y);
    for (int i = 0; i < z.size(); i++) {
        testIndices[i + 2] = variables.indexOf(z.get(i));
    }
    // the following is lame code--need a better test
    for (int i = 0; i < testIndices.length; i++) {
        if (testIndices[i] < 0) {
            throw new IllegalArgumentException("Variable " + i + " was not used in the constructor.");
        }
    }
    // System.out.println("Testing " + x + " _||_ " + y + " | " + z);
    GSquareTest.Result result = gSquareTest.calcGSquare(testIndices);
    this.gSquare = result.getGSquare();
    this.pValue = result.getPValue();
    if (result.isIndep()) {
        StringBuilder sb = new StringBuilder();
        sb.append("INDEPENDENCE ACCEPTED: ");
        sb.append(SearchLogUtils.independenceFact(x, y, z));
        sb.append("\tp = ").append(nf.format(result.getPValue())).append("\tg^2 = ").append(nf.format(result.getGSquare())).append("\tdf = ").append(result.getDf());
        TetradLogger.getInstance().log("independencies", sb.toString());
    } else {
        StringBuilder sb = new StringBuilder();
        sb.append("Not independent: ");
        sb.append(SearchLogUtils.independenceFact(x, y, z));
        sb.append("\tp = ").append(nf.format(result.getPValue())).append("\tg^2 = ").append(nf.format(result.getGSquare())).append("\tdf = ").append(result.getDf());
        TetradLogger.getInstance().log("independencies", sb.toString());
    }
    return result.isIndep();
}
Also used : Node(edu.cmu.tetrad.graph.Node)

Example 75 with Node

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

the class IndTestMulti 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)

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