R arm of morie.fn.elnetr, lasr and pcaprx.
Elnetr minimises \((1/(2n))||y - b_0 - Xb||^2 + \alpha\rho||b||_1 +
\alpha(1-\rho)||b||^2/2\) by cyclic coordinate descent on centred columns
(soft-threshold updates, sweeps stop when the largest coefficient change is
below 1e-8); Lasr is the case \(\rho = 1\). Pcaprx
eigendecomposes the sample covariance (or correlation, when
standardize = TRUE) matrix, orders components by decreasing eigenvalue
and signs each so its largest-magnitude loading is positive.
Usage
Elnetr(X, y, alpha = 1, l1_ratio = 0.5, fit_intercept = TRUE, max_iter = 10000)
Lasr(X, y, alpha = 1, fit_intercept = TRUE, max_iter = 10000)
Pcaprx(X, n_components = NULL, standardize = TRUE)Arguments
- X
Numeric matrix (n by p).
- y
Response vector.
- alpha
Overall penalty.
- l1_ratio
L1 share of the penalty (1 = lasso, 0 = ridge).
- fit_intercept
Centre and fit an unpenalised intercept.
- max_iter
Maximum number of coordinate-descent sweeps.
- n_components
Components retained (all when
NULL).- standardize
Scale columns by their sample standard deviation first.
References
Tibshirani, R. (1996). Regression shrinkage and selection via the lasso. Journal of the Royal Statistical Society B 58(1), 267-288.
Zou, H. and Hastie, T. (2005). Regularization and variable selection via the elastic net. Journal of the Royal Statistical Society B 67(2), 301-320.
Friedman, J., Hastie, T. and Tibshirani, R. (2010). Regularization paths for generalized linear models via coordinate descent. Journal of Statistical Software 33(1), 1-22.
Jolliffe, I. T. (2002). Principal Component Analysis, 2nd ed. Springer.
