Numerix v0.4.2 Numerix.LinearRegression

Linear regression functions.

Summary

Functions

Least squares best fit for points {x, y} to a line y:x↦a+bx where x is the predictor and y the response

Estimates a response y given a predictor x and a set of predictors and responses, i.e. it calculates y in y:x↦a+bx

Measures how close the observed data are to the fitted regression line, i.e. how accurate the prediction is given the actual data

Functions

fit(xs, ys)
fit([number], [number]) :: {float, float}

Least squares best fit for points {x, y} to a line y:x↦a+bx where x is the predictor and y the response.

Returns a tuple containing the intercept a and slope b.

predict(x, xs, ys)
predict(number, [number], [number]) :: number

Estimates a response y given a predictor x and a set of predictors and responses, i.e. it calculates y in y:x↦a+bx.

r_squared(predicted, actual)
r_squared([number], [number]) :: float

Measures how close the observed data are to the fitted regression line, i.e. how accurate the prediction is given the actual data.

Returns a value between 0 and 1 where 0 indicates a prediction that is worse than the mean and 1 indicates a perfect prediction.