public class LinearRegression extends java.lang.Object
Constructor and Description |
---|
LinearRegression(double[] x,
double[] y)
Performs a linear regression on the data points (y[i], x[i]).
|
Modifier and Type | Method and Description |
---|---|
double |
intercept()
Returns the y-intercept α of the best of the best-fit line y = α + β x.
|
double |
interceptStdErr()
Returns the standard error of the estimate for the intercept.
|
double |
predict(double x)
Returns the expected response y given the value of the predictor
variable x.
|
double |
R2()
Returns the coefficient of determination R2.
|
double |
slope()
Returns the slope β of the best of the best-fit line y = α + β x.
|
double |
slopeStdErr()
Returns the standard error of the estimate for the slope.
|
java.lang.String |
toString()
Returns a string representation of the simple linear regression model.
|
public LinearRegression(double[] x, double[] y)
x
- the values of the predictor variabley
- the corresponding values of the response variablejava.lang.IllegalArgumentException
- if the lengths of the two arrays are not equalpublic double intercept()
public double slope()
public double R2()
public double interceptStdErr()
public double slopeStdErr()
public double predict(double x)
x
- the value of the predictor variablepublic java.lang.String toString()
toString
in class java.lang.Object