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;
}
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;
}
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;
}
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();
}
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;
}
Aggregations