# IWLSridge: Iterative weighted least squares algorithm for linear and... In multiridge: Fast Cross-Validation for Multi-Penalty Ridge Regression

## Description

Iterative weighted least squares algorithm for linear and logistic ridge regression. Updates the weights and linear predictors until convergence.

## Usage

 ```1 2``` ```IWLSridge(XXT, Y, X1 = NULL, intercept = TRUE, frac1 = NULL, eps = 1e-07, maxItr = 25, trace = FALSE, model = NULL, E0 = NULL) ```

## Arguments

 `XXT` Matrix. Dimensions `nxn`. Sample cross-product from penalized variables, usually computed by `SigmaFromBlocks`. `Y` Response vector: numeric, binary, or two-class factor `X1` Matrix. Dimension `n x p_0, p_0 < n`, representing unpenalized covariates. `intercept` Boolean. Should an intercept be included? `frac1` Scalar. Prior fraction of cases. Only relevant for `model="logistic"`. `eps` Scalar. Numerical bound for IWLS convergence. `maxItr` Integer. Maximum number of iterations used in IWLS. `trace` Boolean. Should the output of the IWLS algorithm be traced? `model` Character. Any of `c("linear", "logistic")`. Is inferred from `Y` when `NULL`. Note that the cox model for survival is covered by the function `IWLSCoxridge`. `E0` Numerical vector or `NULL`. Optional initial values for linear predictor. Same length as `Y`. Usually `NULL`, which initializes linear predictor with 0.

## Details

An (unpenalized) intercept is included by default. To keep the function computationally efficient it returns the linear predictors (which suffice for predictions), instead of parameter estimates. These may be obtained by applying the `betasout` function to the output of this function.

## Value

List, containing:

 `etas` Numerical vector: Final linear predictors `Ypred` Predicted survival `convergence` Boolean: has IWLS converged? `nIt` Number of iterations `Hres` Auxiliary list object. Passed on to other functions `linearized` Linearized predictions `unpen` Boolean: are there any unpenalized covariates involved? Passed on to other functions `intercept` Boolean: Is an intercept included? `eta0` Numerical vector: Initial linear predictors `X1` Matrix: design matrix unpenalized variables

## References

Mark A. van de Wiel, Mirrelijn van Nee, Armin Rauschenberger (2021). Fast cross-validation for high-dimensional ridge regression. J Comp Graph Stat

`IWLSCoxridge` for Cox ridge. `betasout` for obtaining parameter estimates. `predictIWLS` for predictions on new samples. A full demo and data are available from:
 ``` 1 2 3 4 5 6 7 8 9 10``` ```data(dataXXmirmeth) resp <- dataXXmirmeth[[1]] XXmirmeth <- dataXXmirmeth[[2]] lambdas <- c(100,1000) # Prepare fitting for the specified penalties. XXT <- SigmaFromBlocks(XXmirmeth,penalties=lambdas) # Fit. fit\$etas contains the n linear predictors fit <- IWLSridge(XXT,Y=resp) ```