/**
   * @param stream
   * @throws IOException
   */
  public void CombinedSeasonalityTest(HtmlStream stream) throws IOException {

    stream.write(HtmlTag.HEADER1, h1, "Combined seasonality test").newLine();
    switch (m_stests.getSummary()) {
      case None:
        stream.write("Identifiable seasonality not present", HtmlStyle.Bold, HtmlStyle.Danger);
        break;
      case ProbablyNone:
        stream.write("Identifiable seasonality probably not present", HtmlStyle.Warning);
        break;
      case Present:
        stream.write("Identifiable seasonality present", HtmlStyle.Success);
        break;
    }
    stream.newLines(2);
  }
 /**
  * @param stream
  * @throws IOException
  */
 @Override
 public void write(HtmlStream stream) throws IOException {
   if (m_si == null) {
     stream.write("Series can't be tested");
     return;
   }
   FKWTests(stream);
   StableSeasonalityTest(stream);
   EvolutionSeasonalityTest(stream);
   CombinedSeasonalityTest(stream);
   //        ResidualSeasonality(stream);
 }
  /**
   * @param stream
   * @throws IOException
   */
  public void EvolutionSeasonalityTest(HtmlStream stream) throws IOException {
    stream.write(HtmlTag.HEADER1, h1, "Evolutive seasonality test").newLine();
    SeasonalityTest stest = m_stests.getEvolutiveSeasonality();

    stream.open(new HtmlTable(0, 400));
    stream.open(HtmlTag.TABLEROW);
    stream.write(new HtmlTableCell("", 100));
    stream.write(new HtmlTableCell("Sum of squares", 100));
    stream.write(new HtmlTableCell("Degrees of freedom", 100));
    stream.write(new HtmlTableCell("Mean square", 100));
    stream.close(HtmlTag.TABLEROW);

    stream.open(HtmlTag.TABLEROW);
    stream.write(new HtmlTableCell("Between years", 100, HtmlStyle.Italic));
    stream.write(new HtmlTableCell(Double.toString(stest.getSSM()), 100));
    stream.write(new HtmlTableCell(Double.toString(stest.getDFInterPeriod()), 100));
    stream.write(
        new HtmlTableCell(Double.toString(stest.getSSM() / stest.getDFInterPeriod()), 100));
    stream.close(HtmlTag.TABLEROW);

    stream.open(HtmlTag.TABLEROW);
    stream.write(new HtmlTableCell("Error", 100, HtmlStyle.Italic));
    stream.write(new HtmlTableCell(Double.toString(stest.getSSR()), 100));
    stream.write(new HtmlTableCell(Double.toString(stest.getDFResidual()), 100));
    stream.write(new HtmlTableCell(Double.toString(stest.getSSR() / stest.getDFResidual()), 100));
    stream.close(HtmlTag.TABLE).newLines(2);

    stream.write("Value: " + stest.getValue()).newLine();
    stream.write("Distribution: " + stest.getDistribution().getDescription()).newLine();
    stream
        .write("PValue: " + df4.format(stest.getPValue()), RPValue(stest.getPValue(), 0.01, 0.05))
        .newLine();
    if (stest.getPValue() > 0.2) {
      stream.write("No evidence of moving seasonality at the 20 per cent level").newLines(2);
    } else if (stest.getPValue() < 0.05) {
      stream
          .write("Moving seasonality present at the 5 per cent level", HtmlStyle.Bold)
          .newLines(2);
    }
  }
  /**
   * @param stream
   * @throws IOException
   */
  public void StableSeasonalityTest(HtmlStream stream) throws IOException {
    stream
        .write(HtmlTag.HEADER1, h1, "Test for the presence of seasonality assuming stability")
        .newLine();
    SeasonalityTest stest = m_stests.getStableSeasonality();

    stream.open(new HtmlTable(0, 400));
    stream.open(HtmlTag.TABLEROW);
    stream.write(new HtmlTableCell("", 100));
    stream.write(new HtmlTableCell("Sum of squares", 100));
    stream.write(new HtmlTableCell("Degrees of freedom", 100));
    stream.write(new HtmlTableCell("Mean square", 100));
    stream.close(HtmlTag.TABLEROW);

    stream.open(HtmlTag.TABLEROW);
    stream.write(new HtmlTableCell("Between months", 100, HtmlStyle.Italic));
    stream.write(new HtmlTableCell(Double.toString(stest.getSSM()), 100));
    stream.write(new HtmlTableCell(Double.toString(stest.getDFInterPeriod()), 100));
    stream.write(
        new HtmlTableCell(Double.toString(stest.getSSM() / stest.getDFInterPeriod()), 100));
    stream.close(HtmlTag.TABLEROW);

    stream.open(HtmlTag.TABLEROW);
    stream.write(new HtmlTableCell("Residual", 100, HtmlStyle.Italic));
    stream.write(new HtmlTableCell(Double.toString(stest.getSSR()), 100));
    stream.write(new HtmlTableCell(Double.toString(stest.getDFResidual()), 100));
    stream.write(new HtmlTableCell(Double.toString(stest.getSSR() / stest.getDFResidual()), 100));
    stream.close(HtmlTag.TABLEROW);

    stream.open(HtmlTag.TABLEROW);
    stream.write(new HtmlTableCell("Total", 100, HtmlStyle.Italic));
    stream.write(new HtmlTableCell(Double.toString(stest.getSSQ()), 100));
    stream.write(new HtmlTableCell(Double.toString(stest.getDFTot()), 100));
    stream.write(new HtmlTableCell(Double.toString(stest.getSSQ() / stest.getDFTot()), 100));
    stream.close(HtmlTag.TABLEROW);
    stream.close(HtmlTag.TABLE).newLine();

    stream.write("Value: " + stest.getValue()).newLine();
    stream.write("Distribution: " + stest.getDistribution().getDescription()).newLine();
    stream.write("PValue: " + df4.format(stest.getPValue()), PValue(stest.getPValue())).newLine();
    if (stest.getPValue() < 0.01) {
      stream.write("Seasonality present at the 1 per cent level").newLines(2);
    } else if (stest.getPValue() > 0.05) {
      stream
          .write("No evidence of seasonality at the 5 per cent level", HtmlStyle.Bold)
          .newLines(2);
    }
  }
  /**
   * @param stream
   * @throws IOException
   */
  public void FKWTests(HtmlStream stream) throws IOException {
    stream.write(HtmlTag.HEADER1, h1, "Non parametric tests for stable seasonality").newLine();
    stream.write(HtmlTag.HEADER2, h2, "Friedman test").newLine();
    stream.write("Friedman statistic = " + df4.format(m_ftest.getValue())).newLine();
    stream.write("Distribution: " + m_ftest.getDistribution().toString()).newLine();
    stream
        .write("P-Value: ")
        .write(df4.format(m_ftest.getPValue()), PValue(m_ftest.getPValue()))
        .newLines(2);
    if (m_ftest.getPValue() < 0.01) {
      stream.write("Stable seasonality present at the 1 per cent level").newLines(2);
    } else if (m_ftest.getPValue() > 0.05) {
      stream.write("No evidence of stable seasonality at the 5 per cent level").newLines(2);
    }

    stream.write(HtmlTag.HEADER2, h2, "Kruskall-Wallis test").newLine();
    KruskalWallisTest kw = m_stests.getNonParametricTestForStableSeasonality();
    stream.write("Kruskall-Wallis statistic = " + Double.toString(kw.getValue())).newLine();
    stream.write("Distribution: " + kw.getDistribution().toString()).newLine();
    stream.write("P-Value: ").write(df4.format(kw.getPValue()), PValue(kw.getPValue())).newLine();
    if (kw.getPValue() < 0.01) {
      stream.write("Stable seasonality present at the 1 per cent level").newLines(2);
    } else if (kw.getPValue() > 0.05) {
      stream.write("No evidence of stable seasonality at the 5 per cent level").newLines(2);
    }
  }