hongooi73 / glmnetUtils

Utilities for glmnet
65 stars 18 forks source link

use.model.frame=TRUE fails when formula LHS is matrix #9

Closed hongooi73 closed 7 years ago

hongooi73 commented 7 years ago
df <- data.frame(x1 = rnorm(10), x2 = rnorm(10), y = rbinom(10, 5, 0.5))
df$ny <- 5 - df$y

glmnet(cbind(ny, y) ~ x1 + x2, data=df, family="binomial", use.model.frame=TRUE)
#Error in glmnet::glmnet(x = xy$x, y = xy$y, weights = xy$weights, offset = xy$offset,  : 
#  number of elements in weights (20) not equal to the number of rows of x (10)