LinearRegressionAggregator

A LinearRegressionAggregator is an Aggregator that performs a linear regression analysis of two numeric values, returning several results encapsulated in a LinearRegressionStats object. If no values were encountered, then all linear regression stat values are NaN, except for the count statistic, which is zero. The LinearRegressionStats object contains data for the best fit line slope and y-intercept, the count of all pairs of values where both values are not null, the r-squared component, the correlation, and the averages of both properties. While this Aggregator does use floating-point calculations, it does not override the terminateDoubleDouble method.

Usage

Create and use a LinearRegressionAggregator, with one of the following methods:

  • Aggregator agg = new LinearRegressionAggregator("propertyOne", "propertyTwo");
  • Aggregator agg = Aggregator.getAggregator("LinearRegression(propertyOne, propertyTwo)");

The values returned by both properties of the object must be numeric.

The following methods are available in the LinearRegressionStats object to retrieve the linear regression values. All of them return a double, except for getCount(), which returns a long.

  • getLineSlope() - Return the slope of the best fit line.
  • getLineIntercept() - Return the y-intercept of the best fit line.
  • getCount() - Return the count of all pairs of values where both values were not null, and thus were able to be used.
  • getRSquared() - Return the r-squared "goodness of fit", or the "coefficient of determination".
  • getCorrelation() - Return the correlation value.
  • getAvg1() - Return the average value of the first property.
  • getAvg2() - Return the average value of the second property.