org.apache.commons.math.distribution.TDistribution Java Examples
The following examples show how to use
org.apache.commons.math.distribution.TDistribution.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PearsonsCorrelation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = FastMath.abs(r * FastMath.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * tDistribution.cumulativeProbability(-t); } } } return new BlockRealMatrix(out); }
Example #2
Source File: PearsonsCorrelationTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Verify that direct t-tests using standard error estimates are consistent * with reported p-values */ public void testStdErrorConsistency() throws Exception { TDistribution tDistribution = new TDistributionImpl(45); RealMatrix matrix = createRealMatrix(swissData, 47, 5); PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix); RealMatrix rValues = corrInstance.getCorrelationMatrix(); RealMatrix pValues = corrInstance.getCorrelationPValues(); RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors(); for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { double t = Math.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j); double p = 2 * (1 - tDistribution.cumulativeProbability(t)); assertEquals(p, pValues.getEntry(i, j), 10E-15); } } }
Example #3
Source File: PearsonsCorrelationTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Verify that direct t-tests using standard error estimates are consistent * with reported p-values */ @Test public void testStdErrorConsistency() throws Exception { TDistribution tDistribution = new TDistributionImpl(45); RealMatrix matrix = createRealMatrix(swissData, 47, 5); PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix); RealMatrix rValues = corrInstance.getCorrelationMatrix(); RealMatrix pValues = corrInstance.getCorrelationPValues(); RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors(); for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { double t = FastMath.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j); double p = 2 * (1 - tDistribution.cumulativeProbability(t)); Assert.assertEquals(p, pValues.getEntry(i, j), 10E-15); } } }
Example #4
Source File: PearsonsCorrelation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * (1 - tDistribution.cumulativeProbability(t)); } } } return new BlockRealMatrix(out); }
Example #5
Source File: PearsonsCorrelation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * (1 - tDistribution.cumulativeProbability(t)); } } } return new BlockRealMatrix(out); }
Example #6
Source File: PearsonsCorrelationTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Verify that direct t-tests using standard error estimates are consistent * with reported p-values */ public void testStdErrorConsistency() throws Exception { TDistribution tDistribution = new TDistributionImpl(45); RealMatrix matrix = createRealMatrix(swissData, 47, 5); PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix); RealMatrix rValues = corrInstance.getCorrelationMatrix(); RealMatrix pValues = corrInstance.getCorrelationPValues(); RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors(); for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { double t = Math.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j); double p = 2 * (1 - tDistribution.cumulativeProbability(t)); assertEquals(p, pValues.getEntry(i, j), 10E-15); } } }
Example #7
Source File: PearsonsCorrelationTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Verify that direct t-tests using standard error estimates are consistent * with reported p-values */ public void testStdErrorConsistency() throws Exception { TDistribution tDistribution = new TDistributionImpl(45); RealMatrix matrix = createRealMatrix(swissData, 47, 5); PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix); RealMatrix rValues = corrInstance.getCorrelationMatrix(); RealMatrix pValues = corrInstance.getCorrelationPValues(); RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors(); for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { double t = Math.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j); double p = 2 * (1 - tDistribution.cumulativeProbability(t)); assertEquals(p, pValues.getEntry(i, j), 10E-15); } } }
Example #8
Source File: PearsonsCorrelation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * (1 - tDistribution.cumulativeProbability(t)); } } } return new BlockRealMatrix(out); }
Example #9
Source File: PearsonsCorrelation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * (1 - tDistribution.cumulativeProbability(t)); } } } return new BlockRealMatrix(out); }
Example #10
Source File: PearsonsCorrelation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * (1 - tDistribution.cumulativeProbability(t)); } } } return new BlockRealMatrix(out); }
Example #11
Source File: Math_69_PearsonsCorrelation_t.java From coming with MIT License | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * tDistribution.cumulativeProbability(-t); } } } return new BlockRealMatrix(out); }
Example #12
Source File: PearsonsCorrelationTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Verify that direct t-tests using standard error estimates are consistent * with reported p-values */ public void testStdErrorConsistency() throws Exception { TDistribution tDistribution = new TDistributionImpl(45); RealMatrix matrix = createRealMatrix(swissData, 47, 5); PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix); RealMatrix rValues = corrInstance.getCorrelationMatrix(); RealMatrix pValues = corrInstance.getCorrelationPValues(); RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors(); for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { double t = Math.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j); double p = 2 * (1 - tDistribution.cumulativeProbability(t)); assertEquals(p, pValues.getEntry(i, j), 10E-15); } } }
Example #13
Source File: PearsonsCorrelationTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Verify that direct t-tests using standard error estimates are consistent * with reported p-values */ public void testStdErrorConsistency() throws Exception { TDistribution tDistribution = new TDistributionImpl(45); RealMatrix matrix = createRealMatrix(swissData, 47, 5); PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix); RealMatrix rValues = corrInstance.getCorrelationMatrix(); RealMatrix pValues = corrInstance.getCorrelationPValues(); RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors(); for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { double t = Math.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j); double p = 2 * (1 - tDistribution.cumulativeProbability(t)); assertEquals(p, pValues.getEntry(i, j), 10E-15); } } }
Example #14
Source File: Nopol2017_0076_t.java From coming with MIT License | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * (1 - tDistribution.cumulativeProbability(t)); } } } return new BlockRealMatrix(out); }
Example #15
Source File: PearsonsCorrelation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = FastMath.abs(r * FastMath.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * tDistribution.cumulativeProbability(-t); } } } return new BlockRealMatrix(out); }
Example #16
Source File: PearsonsCorrelation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * (1 - tDistribution.cumulativeProbability(t)); } } } return new BlockRealMatrix(out); }
Example #17
Source File: PearsonsCorrelationTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Verify that direct t-tests using standard error estimates are consistent * with reported p-values */ public void testStdErrorConsistency() throws Exception { TDistribution tDistribution = new TDistributionImpl(45); RealMatrix matrix = createRealMatrix(swissData, 47, 5); PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix); RealMatrix rValues = corrInstance.getCorrelationMatrix(); RealMatrix pValues = corrInstance.getCorrelationPValues(); RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors(); for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { double t = Math.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j); double p = 2 * (1 - tDistribution.cumulativeProbability(t)); assertEquals(p, pValues.getEntry(i, j), 10E-15); } } }
Example #18
Source File: PearsonsCorrelationTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Verify that direct t-tests using standard error estimates are consistent * with reported p-values */ public void testStdErrorConsistency() throws Exception { TDistribution tDistribution = new TDistributionImpl(45); RealMatrix matrix = createRealMatrix(swissData, 47, 5); PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix); RealMatrix rValues = corrInstance.getCorrelationMatrix(); RealMatrix pValues = corrInstance.getCorrelationPValues(); RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors(); for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { double t = Math.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j); double p = 2 * (1 - tDistribution.cumulativeProbability(t)); assertEquals(p, pValues.getEntry(i, j), 10E-15); } } }
Example #19
Source File: PearsonsCorrelation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * (1 - tDistribution.cumulativeProbability(t)); } } } return new BlockRealMatrix(out); }
Example #20
Source File: PearsonsCorrelation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * (1 - tDistribution.cumulativeProbability(t)); } } } return new BlockRealMatrix(out); }
Example #21
Source File: PearsonsCorrelationTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Verify that direct t-tests using standard error estimates are consistent * with reported p-values */ public void testStdErrorConsistency() throws Exception { TDistribution tDistribution = new TDistributionImpl(45); RealMatrix matrix = createRealMatrix(swissData, 47, 5); PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix); RealMatrix rValues = corrInstance.getCorrelationMatrix(); RealMatrix pValues = corrInstance.getCorrelationPValues(); RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors(); for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { double t = FastMath.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j); double p = 2 * (1 - tDistribution.cumulativeProbability(t)); assertEquals(p, pValues.getEntry(i, j), 10E-15); } } }
Example #22
Source File: PearsonsCorrelationTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Verify that direct t-tests using standard error estimates are consistent * with reported p-values */ public void testStdErrorConsistency() throws Exception { TDistribution tDistribution = new TDistributionImpl(45); RealMatrix matrix = createRealMatrix(swissData, 47, 5); PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix); RealMatrix rValues = corrInstance.getCorrelationMatrix(); RealMatrix pValues = corrInstance.getCorrelationPValues(); RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors(); for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { double t = Math.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j); double p = 2 * (1 - tDistribution.cumulativeProbability(t)); assertEquals(p, pValues.getEntry(i, j), 10E-15); } } }
Example #23
Source File: PearsonsCorrelation.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns a matrix of p-values associated with the (two-sided) null * hypothesis that the corresponding correlation coefficient is zero. * <p><code>getCorrelationPValues().getEntry(i,j)</code> is the probability * that a random variable distributed as <code>t<sub>n-2</sub></code> takes * a value with absolute value greater than or equal to <br> * <code>|r|((n - 2) / (1 - r<sup>2</sup>))<sup>1/2</sup></code></p> * <p>The values in the matrix are sometimes referred to as the * <i>significance</i> of the corresponding correlation coefficients.</p> * * @return matrix of p-values * @throws MathException if an error occurs estimating probabilities */ public RealMatrix getCorrelationPValues() throws MathException { TDistribution tDistribution = new TDistributionImpl(nObs - 2); int nVars = correlationMatrix.getColumnDimension(); double[][] out = new double[nVars][nVars]; for (int i = 0; i < nVars; i++) { for (int j = 0; j < nVars; j++) { if (i == j) { out[i][j] = 0d; } else { double r = correlationMatrix.getEntry(i, j); double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r))); out[i][j] = 2 * (1 - tDistribution.cumulativeProbability(t)); } } } return new BlockRealMatrix(out); }
Example #24
Source File: PearsonsCorrelationTest.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Verify that direct t-tests using standard error estimates are consistent * with reported p-values */ public void testStdErrorConsistency() throws Exception { TDistribution tDistribution = new TDistributionImpl(45); RealMatrix matrix = createRealMatrix(swissData, 47, 5); PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix); RealMatrix rValues = corrInstance.getCorrelationMatrix(); RealMatrix pValues = corrInstance.getCorrelationPValues(); RealMatrix stdErrors = corrInstance.getCorrelationStandardErrors(); for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { double t = Math.abs(rValues.getEntry(i, j)) / stdErrors.getEntry(i, j); double p = 2 * (1 - tDistribution.cumulativeProbability(t)); assertEquals(p, pValues.getEntry(i, j), 10E-15); } } }
Example #25
Source File: SimpleRegression.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Modify the distribution used to compute inference statistics. * @param value the new distribution * @since 1.2 */ public void setDistribution(TDistribution value) { distribution = value; // modify degrees of freedom if (n > 2) { distribution.setDegreesOfFreedom(n - 2); } }
Example #26
Source File: SimpleRegression.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Modify the distribution used to compute inference statistics. * @param value the new distribution * @since 1.2 */ public void setDistribution(TDistribution value) { distribution = value; // modify degrees of freedom if (n > 2) { distribution.setDegreesOfFreedom(n - 2); } }
Example #27
Source File: SimpleRegression.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Modify the distribution used to compute inference statistics. * @param value the new distribution * @since 1.2 */ public void setDistribution(TDistribution value) { distribution = value; // modify degrees of freedom if (n > 2) { distribution.setDegreesOfFreedom(n - 2); } }
Example #28
Source File: SimpleRegression.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Modify the distribution used to compute inference statistics. * @param value the new distribution * @since 1.2 */ public void setDistribution(TDistribution value) { distribution = value; // modify degrees of freedom if (n > 2) { distribution.setDegreesOfFreedom(n - 2); } }
Example #29
Source File: SimpleRegression.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Modify the distribution used to compute inference statistics. * @param value the new distribution * @since 1.2 */ public void setDistribution(TDistribution value) { distribution = value; // modify degrees of freedom if (n > 2) { distribution.setDegreesOfFreedom(n - 2); } }
Example #30
Source File: SimpleRegression.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Modify the distribution used to compute inference statistics. * @param value the new distribution * @since 1.2 */ public void setDistribution(TDistribution value) { distribution = value; // modify degrees of freedom if (n > 2) { distribution.setDegreesOfFreedom(n - 2); } }