Create a gist now

Instantly share code, notes, and snippets.

glmnet.mock <- function(formula=y~., family="gaussian", data, ...){
fam.link <- strsplit(family, "\\(|\\)")[[1]]
family <- fam.link[1]
if(length(fam.link) >=2) link <- fam.link[2]
else link <- "identity"
depvar <- strsplit(as.character(formula)[2], "+", T)[[1]]
return(glmnet(x=model.matrix(formula, data)[,-1], y=get(link)(data[,depvar]), family = family, ...))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment