Nothing
LassoPath <- function (data, formula) {
# LASSO path for penalized logistic regression.
#
# Args:
# data: a data frame containing the treatment, the outcome and the predictors.
# formula: an object of class "formula" (or one that can be coerced to that class):
# a symbolic description of the model to be fitted.
# Returns:
# A dataframe containing the coefficients values and the number of nonzeros coefficients.
X <- model.matrix(formula, data)
y <- model.frame(formula, data)[, 1]
get_lambdas <- cv.glmnet(X,
y,
family="binomial",
type.measure="auc",
nfolds=3)
glmnet.output <- glmnet(X, y, alpha = 1, family = "binomial",
lambda = get_lambdas$lambda,
standardize=TRUE,
intercept = FALSE,
type.logistic = "modified.Newton")
dimension <- glmnet.output$df
coeff <- t(as.matrix(glmnet.output$beta))
lambda <- glmnet.output$lambda
path <- cbind(lambda, dimension, coeff)
class(path) <- "LassoPath"
return(path)
}
# END FUN
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.