Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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"
return(glmnet(x=model.matrix(formula, data),
y=get(link)(model.response(model.frame(formula, data))),
family = family,
...)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment