Estimates an ordinary least squares regression model with one independent variable.
y = intercept + slope * x
Standard errors for intercept
and slope
are available as well as ANOVA, r-square and Pearson's r statistics.
Observations (x,y pairs) can be added to the model one at a time or they can be provided in a 2-dimensional array. The observations are not stored in memory, so there is no limit to the number of observations that can be added to the model.
Usage Notes:
- When there are fewer than two observations in the model, or when there is no variation in the x values (i.e. all x values are the same) all statistics return
NaN
. At least two observations with different x coordinates are required to estimate a bivariate regression model. - Getters for the statistics always compute values based on the current set of observations -- i.e., you can get statistics, then add more data and get updated statistics without using a new instance. There is no "compute" method that updates all statistics. Each of the getters performs the necessary computations to return the requested statistic.
- The intercept term may be suppressed by passing {@code false} tothe {@link #SimpleRegression(boolean)} constructor. When the{@code hasIntercept} property is false, the model is estimated without aconstant term and {@link #getIntercept()} returns {@code 0}.