TTestOutcome.java

  1. package org.drip.validation.hypothesis;

  2. /*
  3.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  4.  */

  5. /*!
  6.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  7.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  8.  *
  9.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  10.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  11.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  12.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  13.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  14.  *      and computational support.
  15.  *  
  16.  *      https://lakshmidrip.github.io/DROP/
  17.  *  
  18.  *  DROP is composed of three modules:
  19.  *  
  20.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  21.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  22.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  23.  *
  24.  *  DROP Product Core implements libraries for the following:
  25.  *  - Fixed Income Analytics
  26.  *  - Loan Analytics
  27.  *  - Transaction Cost Analytics
  28.  *
  29.  *  DROP Portfolio Core implements libraries for the following:
  30.  *  - Asset Allocation Analytics
  31.  *  - Asset Liability Management Analytics
  32.  *  - Capital Estimation Analytics
  33.  *  - Exposure Analytics
  34.  *  - Margin Analytics
  35.  *  - XVA Analytics
  36.  *
  37.  *  DROP Computational Core implements libraries for the following:
  38.  *  - Algorithm Support
  39.  *  - Computation Support
  40.  *  - Function Analysis
  41.  *  - Model Validation
  42.  *  - Numerical Analysis
  43.  *  - Numerical Optimizer
  44.  *  - Spline Builder
  45.  *  - Statistical Learning
  46.  *
  47.  *  Documentation for DROP is Spread Over:
  48.  *
  49.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  50.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  51.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  52.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  53.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  54.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  55.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  56.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  57.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  58.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  59.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  60.  *
  61.  *  Licensed under the Apache License, Version 2.0 (the "License");
  62.  *      you may not use this file except in compliance with the License.
  63.  *  
  64.  *  You may obtain a copy of the License at
  65.  *      http://www.apache.org/licenses/LICENSE-2.0
  66.  *  
  67.  *  Unless required by applicable law or agreed to in writing, software
  68.  *      distributed under the License is distributed on an "AS IS" BASIS,
  69.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  70.  *  
  71.  *  See the License for the specific language governing permissions and
  72.  *      limitations under the License.
  73.  */

  74. /**
  75.  * <i>TTestOutcome</i> holds the Results of a Statistic Hypothesis t-Test.
  76.  *
  77.  *  <br><br>
  78.  *  <ul>
  79.  *      <li>
  80.  *          Bhattacharya, B., and D. Habtzghi (2002): Median of the p-value under the Alternate Hypothesis
  81.  *              American Statistician 56 (3) 202-206
  82.  *      </li>
  83.  *      <li>
  84.  *          Head, M. L., L. Holman, R, Lanfear, A. T. Kahn, and M. D. Jennions (2015): The Extent and
  85.  *              Consequences of p-Hacking in Science PLoS Biology 13 (3) e1002106
  86.  *      </li>
  87.  *      <li>
  88.  *          Wasserstein, R. L., and N. A. Lazar (2016): The ASA’s Statement on p-values: Context, Process,
  89.  *              and Purpose American Statistician 70 (2) 129-133
  90.  *      </li>
  91.  *      <li>
  92.  *          Wikipedia (2018): t-statistic https://en.wikipedia.org/wiki/T-statistic
  93.  *      </li>
  94.  *      <li>
  95.  *          Wikipedia (2019): p-value https://en.wikipedia.org/wiki/P-value
  96.  *      </li>
  97.  *  </ul>
  98.  *
  99.  *  <br><br>
  100.  *  <ul>
  101.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  102.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ModelValidationAnalyticsLibrary.md">Model Validation Analytics Library</a></li>
  103.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/validation/README.md">Risk Factor and Hypothesis Validation, Evidence Processing, and Model Testing</a></li>
  104.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/validation/hypothesis/README.md">Statistical Hypothesis Validation Test Suite</a></li>
  105.  *  </ul>
  106.  * <br><br>
  107.  *
  108.  * @author Lakshmi Krishnamurthy
  109.  */

  110. public class TTestOutcome
  111. {
  112.     private double _ensembleMean = java.lang.Double.NaN;
  113.     private double _testStatistic = java.lang.Double.NaN;
  114.     private int _sampleCount = java.lang.Integer.MIN_VALUE;
  115.     private double _ensembleVariance = java.lang.Double.NaN;
  116.     private double _ensembleTStatistics = java.lang.Double.NaN;
  117.     private double _ensembleStandardError = java.lang.Double.NaN;
  118.     private double _ensembleStandardDeviation = java.lang.Double.NaN;
  119.     private double _ensembleStandardErrorOffset = java.lang.Double.NaN;
  120.     private int _ensembleDegreesOfFreedom = java.lang.Integer.MIN_VALUE;
  121.     private double _ensemblePredictiveConfidenceInterval = java.lang.Double.NaN;

  122.     /**
  123.      * TTestOutcome Constructor
  124.      *
  125.      * @param testStatistic Sample Test Statistic
  126.      * @param sampleCount Number of Samples in the Ensemble
  127.      * @param ensembleMean Ensemble Mean
  128.      * @param ensembleVariance Ensemble Variance
  129.      * @param ensembleStandardDeviation Ensemble Standard Deviation
  130.      * @param ensembleStandardError Ensemble Standard Error
  131.      * @param ensembleDegreesOfFreedom Ensemble Degrees of Freedom
  132.      * @param ensemblePredictiveConfidenceInterval Ensemble Predictive Confidence Interval
  133.      * @param ensembleTStatistics Ensemble t-Statistics
  134.      * @param ensembleStandardErrorOffset  Ensemble Standard Error Offset
  135.      *
  136.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  137.      */

  138.     public TTestOutcome (
  139.         final double testStatistic,
  140.         final int sampleCount,
  141.         final double ensembleMean,
  142.         final double ensembleVariance,
  143.         final double ensembleStandardDeviation,
  144.         final double ensembleStandardError,
  145.         final int ensembleDegreesOfFreedom,
  146.         final double ensemblePredictiveConfidenceInterval,
  147.         final double ensembleTStatistics,
  148.         final double ensembleStandardErrorOffset)
  149.         throws java.lang.Exception
  150.     {
  151.         if (!org.drip.numerical.common.NumberUtil.IsValid (_testStatistic = testStatistic) ||
  152.             0 >= (_sampleCount = sampleCount) ||
  153.             !org.drip.numerical.common.NumberUtil.IsValid (_ensembleMean = ensembleMean) ||
  154.             !org.drip.numerical.common.NumberUtil.IsValid (_ensembleVariance = ensembleVariance) ||
  155.             !org.drip.numerical.common.NumberUtil.IsValid (_ensembleStandardDeviation =
  156.                 ensembleStandardDeviation) ||
  157.             !org.drip.numerical.common.NumberUtil.IsValid (_ensembleStandardError = ensembleStandardError) ||
  158.             0 > (_ensembleDegreesOfFreedom = ensembleDegreesOfFreedom) ||
  159.             !org.drip.numerical.common.NumberUtil.IsValid (_ensemblePredictiveConfidenceInterval =
  160.                 ensemblePredictiveConfidenceInterval) ||
  161.             !org.drip.numerical.common.NumberUtil.IsValid (_ensembleTStatistics = ensembleTStatistics) ||
  162.             !org.drip.numerical.common.NumberUtil.IsValid (_ensembleStandardErrorOffset =
  163.                 ensembleStandardErrorOffset))
  164.         {
  165.             throw new java.lang.Exception ("TTestOutcome Constructor => Invalid Inputs");
  166.         }
  167.     }

  168.     /**
  169.      * Retrieve the Sample Test Statistic
  170.      *
  171.      * @return The Sample Test Statistic
  172.      */

  173.     public double testStatistic()
  174.     {
  175.         return _testStatistic;
  176.     }

  177.     /**
  178.      * Retrieve the Sample Count
  179.      *
  180.      * @return The Sample Count
  181.      */

  182.     public int sampleCount()
  183.     {
  184.         return _sampleCount;
  185.     }

  186.     /**
  187.      * Retrieve the Ensemble Mean
  188.      *
  189.      * @return The Ensemble Mean
  190.      */

  191.     public double ensembleMean()
  192.     {
  193.         return _ensembleMean;
  194.     }

  195.     /**
  196.      * Retrieve the Ensemble Variance
  197.      *
  198.      * @return The Ensemble Variance
  199.      */

  200.     public double ensembleVariance()
  201.     {
  202.         return _ensembleVariance;
  203.     }

  204.     /**
  205.      * Retrieve the Ensemble Standard Deviation
  206.      *
  207.      * @return The Ensemble Standard Deviation
  208.      */

  209.     public double ensembleStandardDeviation()
  210.     {
  211.         return _ensembleStandardDeviation;
  212.     }

  213.     /**
  214.      * Retrieve the Ensemble Standard Error
  215.      *
  216.      * @return The Ensemble Standard Error
  217.      */

  218.     public double ensembleStandardError()
  219.     {
  220.         return _ensembleStandardError;
  221.     }

  222.     /**
  223.      * Retrieve the Ensemble Degrees of Freedom
  224.      *
  225.      * @return The Ensemble Degrees of Freedom
  226.      */

  227.     public int ensembleDegreesOfFreedom()
  228.     {
  229.         return _ensembleDegreesOfFreedom;
  230.     }

  231.     /**
  232.      * Retrieve the Ensemble Predictive Confidence Interval
  233.      *
  234.      * @return The Ensemble Predictive Confidence Interval
  235.      */

  236.     public double ensemblePredictiveConfidenceInterval()
  237.     {
  238.         return _ensemblePredictiveConfidenceInterval;
  239.     }

  240.     /**
  241.      * Retrieve the Ensemble t-Statistics
  242.      *
  243.      * @return The Ensemble t-Statistics
  244.      */

  245.     public double ensembleTStatistics()
  246.     {
  247.         return _ensembleTStatistics;
  248.     }

  249.     /**
  250.      * Retrieve the Ensemble Standard Error Offset
  251.      *
  252.      * @return The Ensemble Standard Error Offset
  253.      */

  254.     public double ensembleStandardErrorOffset()
  255.     {
  256.         return _ensembleStandardErrorOffset;
  257.     }
  258. }