@Test
  public void test7() {
    RandomUtil.getInstance().setSeed(29999483L);

    List<Node> nodes = new ArrayList<>();
    int numVars = 10;

    for (int i = 0; i < numVars; i++) nodes.add(new ContinuousVariable("X" + (i + 1)));

    Graph graph =
        GraphUtils.randomGraphRandomForwardEdges(nodes, 0, numVars, 30, 15, 15, false, true);

    GeneralizedSemPm pm = new GeneralizedSemPm(graph);
    GeneralizedSemIm im = new GeneralizedSemIm(pm);

    print(im);

    DataSet data = im.simulateDataRecursive(1000, false);

    GeneralizedSemEstimator estimator = new GeneralizedSemEstimator();
    GeneralizedSemIm estIm = estimator.estimate(pm, data);

    print(estIm);
    print(estimator.getReport());

    double aSquaredStar = estimator.getaSquaredStar();

    assertEquals(0.67, aSquaredStar, 0.01);
  }
  @Test
  public void test6() {
    RandomUtil.getInstance().setSeed(29999483L);

    int numVars = 5;

    List<Node> nodes = new ArrayList<>();
    for (int i = 0; i < numVars; i++) nodes.add(new ContinuousVariable("X" + (i + 1)));

    Graph graph =
        GraphUtils.randomGraphRandomForwardEdges(nodes, 0, numVars, 30, 15, 15, false, true);

    SemPm spm = new SemPm(graph);

    SemImInitializationParams params = new SemImInitializationParams();
    params.setCoefRange(0.5, 1.5);
    params.setVarRange(1, 3);

    SemIm sim = new SemIm(spm, params);

    GeneralizedSemPm pm = new GeneralizedSemPm(spm);
    GeneralizedSemIm im = new GeneralizedSemIm(pm, sim);

    DataSet data = im.simulateData(1000, false);

    print(im);

    GeneralizedSemEstimator estimator = new GeneralizedSemEstimator();
    GeneralizedSemIm estIm = estimator.estimate(pm, data);

    print(estIm);
    print(estimator.getReport());

    double aSquaredStar = estimator.getaSquaredStar();

    assertEquals(0.59, aSquaredStar, 0.01);
  }