R - Logistic Regression - Sparse Matrix -
i have dataset has 1000 features , 30,000 rows. of data 0's. storing information in sparse matrix. perform column wise logistic regression - each feature vs dependent variable.
my question how perform logistic regression on sparse matrices.i stumbled glmnet package requires minimum 2 columns. here sample code
require(glmnet) x = matrix(rnorm(100*1),100,1) y = rnorm(100) glmnet(x,y)
this gives me error. wondering if there other package might have missed?
any appreciated. all
this more workaround solution. can add column 1s (cbind(1, x)
) one-column matrix. new column used estimating intercept. therefore, have use argument intercept = false
.
glmnet(cbind(1, x), y, intercept = false)
Comments
Post a Comment