/**
* Test Longley dataset against R.
*/
public void testLongly() throws Exception {
RealMatrix matrix = createRealMatrix(longleyData, 16, 7);
PearsonsCorrelation corrInstance = new PearsonsCorrelation(matrix);
RealMatrix correlationMatrix = corrInstance.getCorrelationMatrix();
double[] rData = new double[] {
1.000000000000000, 0.9708985250610560, 0.9835516111796693, 0.5024980838759942,
0.4573073999764817, 0.960390571594376, 0.9713294591921188,
0.970898525061056, 1.0000000000000000, 0.9915891780247822, 0.6206333925590966,
0.4647441876006747, 0.979163432977498, 0.9911491900672053,
0.983551611179669, 0.9915891780247822, 1.0000000000000000, 0.6042609398895580,
0.4464367918926265, 0.991090069458478, 0.9952734837647849,
0.502498083875994, 0.6206333925590966, 0.6042609398895580, 1.0000000000000000,
-0.1774206295018783, 0.686551516365312, 0.6682566045621746,
0.457307399976482, 0.4647441876006747, 0.4464367918926265, -0.1774206295018783,
1.0000000000000000, 0.364416267189032, 0.4172451498349454,
0.960390571594376, 0.9791634329774981, 0.9910900694584777, 0.6865515163653120,
0.3644162671890320, 1.000000000000000, 0.9939528462329257,
0.971329459192119, 0.9911491900672053, 0.9952734837647849, 0.6682566045621746,
0.4172451498349454, 0.993952846232926, 1.0000000000000000
};
TestUtils.assertEquals("correlation matrix", createRealMatrix(rData, 7, 7), correlationMatrix, 10E-15);
double[] rPvalues = new double[] {
4.38904690369668e-10,
8.36353208910623e-12, 7.8159700933611e-14,
0.0472894097790304, 0.01030636128354301, 0.01316878049026582,
0.0749178049642416, 0.06971758330341182, 0.0830166169296545, 0.510948586323452,
3.693245043123738e-09, 4.327782576751815e-11, 1.167954621905665e-13, 0.00331028281967516, 0.1652293725106684,
3.95834476307755e-10, 1.114663916723657e-13, 1.332267629550188e-15, 0.00466039138541463, 0.1078477071581498, 7.771561172376096e-15
};
RealMatrix rPMatrix = createLowerTriangularRealMatrix(rPvalues, 7);
fillUpper(rPMatrix, 0d);
TestUtils.assertEquals("correlation p values", rPMatrix, corrInstance.getCorrelationPValues(), 10E-15);
}