Implements ordinary least squares (OLS) to estimate the parameters of a multiple linear regression model.
The regression coefficients, b
, satisfy the normal equations:
XT X b = XT y
To solve the normal equations, this implementation uses QR decomposition of the X
matrix. (See {@link QRDecomposition} for details on thedecomposition algorithm.) The X
matrix, also known as the design matrix, has rows corresponding to sample observations and columns corresponding to independent variables. When the model is estimated using an intercept term (i.e. when {@link #isNoIntercept() isNoIntercept} is false as it is by default), the X
matrix includes an initial column identically equal to 1. We solve the normal equations as follows:
XTX b = XT y (QR)T (QR) b = (QR)Ty RT (QTQ) R b = RT QT y RT R b = RT QT y (RT)-1 RT R b = (RT)-1 RT QT y R b = QT y
Given Q
and R
, the last equation is solved by back-substitution.
@since 2.0