private boolean isIndependentMultinomialLogisticRegression(Node x, Node y, List<Node> z) {
    double p = dependencePvalsLogit(x, y, z)[0];
    boolean indep = p > alpha;
    // 0 corresponds to y
    this.lastP = p;

    if (indep) {
      TetradLogger.getInstance()
          .log("independencies", SearchLogUtils.independenceFactMsg(x, y, z, p));
    } else {
      TetradLogger.getInstance().log("dependencies", SearchLogUtils.dependenceFactMsg(x, y, z, p));
    }

    return indep;
  }
  private boolean isIndependentRegression(Node x, Node y, List<Node> z) {
    double p = dependencePvalsLinear(x, y, z)[0];
    // result.getP()[1];
    this.lastP = p;

    boolean indep = p > alpha;

    if (verbose) {
      if (indep) {
        TetradLogger.getInstance()
            .log("independencies", SearchLogUtils.independenceFactMsg(x, y, z, p));
      } else {
        TetradLogger.getInstance()
            .log("dependencies", SearchLogUtils.dependenceFactMsg(x, y, z, p));
      }
    }

    return indep;
  }
예제 #3
0
  /** Tests to see if d separation facts are symmetric. */
  public void testDSeparation() {
    EdgeListGraphSingleConnections graph =
        new EdgeListGraphSingleConnections(
            new Dag(GraphUtils.randomGraph(7, 0, 7, 30, 15, 15, true)));
    System.out.println(graph);

    List<Node> nodes = graph.getNodes();

    int depth = -1;

    for (int i = 0; i < nodes.size(); i++) {
      for (int j = i + 1; j < nodes.size(); j++) {
        Node x = nodes.get(i);
        Node y = nodes.get(j);

        List<Node> theRest = new ArrayList<Node>(nodes);
        theRest.remove(x);
        theRest.remove(y);

        DepthChoiceGenerator gen = new DepthChoiceGenerator(theRest.size(), depth);
        int[] choice;

        while ((choice = gen.next()) != null) {
          List<Node> z = new LinkedList<Node>();

          for (int k = 0; k < choice.length; k++) {
            z.add(theRest.get(choice[k]));
          }

          if (graph.isDSeparatedFrom(x, y, z) != graph.isDSeparatedFrom(y, x, z)) {
            fail(
                SearchLogUtils.independenceFact(x, y, z)
                    + " should have same d-sep result as "
                    + SearchLogUtils.independenceFact(y, x, z));
          }
        }
      }
    }
  }