i'd like to do large-scale regression (linear/logistic) in R with many (e.g. 100k) features, where each example is relatively sparse in the feature space---e.g., ~1k non-zero features per example.
it seems like the SparseM package slm
should do this, but i'm having difficulty converting from the sparseMatrix
format to a slm
-friendly format.
i have a numeric vector of labels y
and a sparseMatrix
of features X
\in {0,1}. when i try
> model <- slm(y ~ X)
i get the following error:
Error in model.frame.default(formula = y ~ X) :
invalid type (S4) for variable 'X'
presumably because slm
wants a SparseM
object instead of a sparseMatrix
.
is there an easy way to either a) populate a SparseM
object directly or b) convert a sparseMatrix
to a SparseM
object? or perhaps there's a better/simpler way to do this?
(i suppose i could explicitly code the solutions for linear regression using X
and y
, but it would be nice to have slm working.)
any help is greatly appreciated.