8.17
linear-regression🔗ℹ
Link to this document with
@other-doc['(lib "linear-regression/scribblings/linear-regression.scrbl")]
Link to this document with
@other-doc['(lib "linear-regression/scribblings/linear-regression.scrbl")]
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🔗ℹ
Link to this section with
@secref["Installation"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
Link to this section with
@secref["Installation"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
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🔗ℹ
Link to this section with
@secref["Using_the_Package"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
Link to this section with
@secref["Using_the_Package"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
The package gives public use to four functions:
csv-transform
coeffs
predict
r2_adj
2.1 csv-transform🔗ℹ
Link to this section with
@secref["csv-transform"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
Link to this section with
@secref["csv-transform"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
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🔗ℹ
Link to this section with
@secref["coeffs"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
Link to this section with
@secref["coeffs"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
This function takes the result from csv-transform and calculates the regression coefficients, as a column matrix.
2.3 predict🔗ℹ
Link to this section with
@secref["predict"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
Link to this section with
@secref["predict"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
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🔗ℹ
Link to this section with
@secref["r2_adj"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
Link to this section with
@secref["r2_adj"
#:doc '(lib "linear-regression/scribblings/linear-regression.scrbl")]
This function takes coefficients (result of coeffs) and data set (result of csv-transform) and calculates the adjusted coefficient of correlation.