linear-regression
(requirelinear-regression) | package:linear-regression |
This pakcage performs the basic tasks of Linear Regression in (base) Racket. It supports univariate as well as multivariate covariates. The code can be found here.
1 Installation
To install this library, use:
raco pkg install linear-regression |
You can keep the package up to date by using
raco pkg update linear-regression |
2 Using the Package
The package gives public use to four functions:
csv-transform
coeffs
predict
r2_adj
2.1 csv-transform
This function takes a csv file as input. More specifically, it is structured by rows: The first row contains the observation data, and any subsequent row is a covariate.
It returns a list of two matrices: the first matrix is the observations, and the other matrix are your covariates (which may be multivariate).
2.2 coeffs
This function takes the result from csv-transform and calculates the regression coefficients, as a column matrix.
2.3 predict
This function takes a matrix of coefficients (the result of coeffs) and a vector of new data, of the correct dimension. It simply returns the predicted value given the coefficients.
2.4 r2_adj
This function takes coefficients (result of coeffs) and data set (result of csv-transform) and calculates the adjusted coefficient of correlation.