Multiple linear regression and variations using Math.NET
As mentioned earlier, a regression model can be found using matrix decomposition such as QR and SVD.
The following code finds the theta from QR decomposition for the same data:
let qrlTheta = MultipleRegression.QR( created2 ,Y_MPG)
When run, this shows the following result in the F# interactive:
Now using these theta values, the predicted miles per gallon for the unknown car can be found by the following code snippet:
let mpgPredicted = qrlTheta * vector[8.;360.;215.;4615.;14.]
Similarly, SVD can be used to find the linear regression coefficients as done for QR:
let svdTheta = MultipleRegression.SVD( created2 ,Y_MPG)