View source: R/penalized.clr.R
penalized.clr | R Documentation |
Fits conditional logistic regression models with L1 and L2 penalty allowing for different penalties for different blocks of covariates.
penalized.clr(
response,
stratum,
penalized,
unpenalized = NULL,
lambda,
alpha = 1,
p = NULL,
standardize = TRUE,
event
)
response |
The response variable, either a 0/1 vector or a factor with two levels. |
stratum |
A numeric vector with stratum membership of each observation. |
penalized |
A matrix of penalized covariates. |
unpenalized |
A matrix of additional unpenalized covariates. |
lambda |
The tuning parameter for L1. Either a single non-negative number, or a numeric vector of the length equal to the number of blocks. See p below. |
alpha |
The elastic net mixing parameter, a number between 0 and 1. alpha=0 would give pure ridge; alpha=1 gives lasso. Pure ridge penalty is never obtained in this implementation since alpha must be positive. |
p |
The sizes of blocks of covariates, a numerical vector of the length equal to the number of blocks, and with the sum equal to the number of penalized covariates. If missing, all covariates are treated the same and a single penalty is applied. |
standardize |
Should the covariates be standardized, a logical value. |
event |
If response is a factor, the level that should be considered a success in the logistic regression. |
The penalized.clr
function fits a conditional logistic regression
model for a given combination of L1 (lambda
) and L2 penalties. L2 penalty is
obtained from lambda
and alpha
as lambda*(1-alpha)/(2*alpha)
.
Note that lambda
is a single number if all covariates are to be penalized
equally, and a vector of penatlies, if predictors are divided in blocks (of sizes provided in
p
) that are to be penalized differently. The penalized.clr
function
is based on the Cox model routine available in the
penalized
package.
A list with the following elements:
penalized
- Regression coefficients for the penalized covariates.
unpenalized
- Regression coefficients for the unpenalized covariates.
converged
- Whether the fitting process was judged to have converged.
lambda
- The tuning parameter for L1 used.
alpha
- The elastic net mixing parameter used.
stable.clr
and stable.clr.g
for variable selection through stability selection
in penalized conditional logistic regression with a single penalty factor and multiple penalty factors, respectively.
set.seed(123)
# simulate covariates (pure noise in two blocks of 20 and 80 variables)
X <- cbind(matrix(rnorm(4000, 0, 1), ncol = 20), matrix(rnorm(16000, 2, 0.6), ncol = 80))
# stratum membership
stratum <- sort(rep(1:100, 2))
# the response
Y <- rep(c(1, 0), 100)
fit <- penalized.clr( response = Y, stratum = stratum,
penalized = X, lambda = c(1, 0.3),
p = c(20, 80), standardize = TRUE)
fit$penalized
fit$converged
fit$lambda
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.