OLSMultipleLinearRegression extends AbstractMultipleLinearRegression { public void newSampleData(double[] y, double[][] x) throws MathIllegalArgumentException { validateSampleData(x, y); newYSampleData(y); newXSampleData(x); } OLSMultipleLinearRegression();  OLSMultipleLinearRegression(final double threshold); void newSampleData(double[] y, double[][] x); @Override void newSampleData(double[] data, int nobs, int nvars); RealMatrix calculateHat(); double calculateTotalSumOfSquares(); double calculateResidualSumOfSquares(); double calculateRSquared(); double calculateAdjustedRSquared();  }
@Test(expected=IllegalArgumentException.class) public void cannotAddSampleDataWithSizeMismatch() { double[] y = new double[]{1.0, 2.0}; double[][] x = new double[1][]; x[0] = new double[]{1.0, 0}; createRegression().newSampleData(y, x); }
@Test public void testYVariance() { OLSMultipleLinearRegression model = new OLSMultipleLinearRegression(); model.newSampleData(y, x); TestUtils.assertEquals(model.calculateYVariance(), 3.5, 0); }
@Test(expected=IllegalArgumentException.class) public void testNewSampleDataYNull() { createRegression().newSampleData(null, new double[][] {}); }
@Test(expected=IllegalArgumentException.class) public void testNewSampleDataXNull() { createRegression().newSampleData(new double[] {}, null); }