/**
* 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);
}
}
}