Class Ols
java.lang.Object
com.quantfinlib.alpha.Ols
Ordinary least squares by Householder QR, with classical and
Newey-West HAC standard errors.
QR rather than the normal equations: solving XᵀX b = Xᵀy
squares the condition number of X, which matters for factor
return streams that are 0.6 to 0.9 correlated. The coefficient
covariance uses (XᵀX)⁻¹ = R⁻¹R⁻ᵀ from the same factorisation.
- Classical:
V = σ̂² (XᵀX)⁻¹,σ̂² = e'e/(n − p). - HAC (Newey and West 1987):
V = (XᵀX)⁻¹ S (XᵀX)⁻¹withS = Σ_t e_t² x_t x_tᵀ + Σ_{l=1..L} w_l Σ_t e_t e_{t−l} (x_t x_{t−l}ᵀ + x_{t−l} x_tᵀ),w_l = 1 − l/(L+1). No small-sample degrees-of-freedom correction is applied.
-
Nested Class Summary
Nested Classes -
Method Summary
-
Method Details
-
fit
Fitsy = X b + e. The caller includes an intercept column if one is wanted.- Parameters:
x- design matrix,x[t][j], n rows by p columns, n > py- response, length nhacLag- Bartlett lag for the HAC errors (0 = White heteroskedasticity-robust errors)- Throws:
IllegalArgumentException- on misaligned input, non-finite values or a rank-deficient design
-