1

When I've used glmnet() in the past, I have used model.matrix() to create my x input for glmnet(x, y, alpha = 1, family = 'binomial'). However, I'm now trying to predict binary outcomes for data in which I have full observations for each of the predictors, but all my entries for the response are NA. The model.matrix() function does not appear to function when the response variables are all missing, and I've been trying to use data.matrix() to construct an alternative x input for glmnet(). However, I keep getting the following error when I try to use the predict() function:

Error in as.matrix(cbind2(1, newx) %*% nbeta) : 
  error in evaluating the argument 'x' in selecting a method for function 'as.matrix': Error in cbind2(1, newx) %*% nbeta : 
  Cholmod error 'X and/or Y have wrong dimensions' at file ../MatrixOps/cholmod_sdmult.c, line 90

Would anyone be able to suggest how to move forward in this scenario with all missing response values? I've tried using various sparse matrix functions after reading several online articles, but none seem to work. For example:

https://stat.ethz.ch/R-manual/R-devel/library/Matrix/html/sparseMatrix.html

kathystehl
  • 831
  • 1
  • 9
  • 26
  • 2
    I'm confused. How would you train a model when you don't have any response values? You need responses to fit a regression model. If you need help choosing an appropriate statistical model for your data, you would be better off posting at [stats.se] where statistical topics are welcomed. Right now this question doesn't sound right for Stack Overflow. you may be able to improve it by including a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with some sample data so we can better see what you are trying to do. – MrFlick Mar 02 '16 at 03:02
  • My apologies--to clarify, I've trained my model on data that does have the response, as well as tested it on data with the response. Now, I just need to make predictions on data that has all of the same predictor variables as my training and test datasets, but has missing values for the response. This shouldn't matter at this point since I am just trying to make a prediction. The issue seems more so that I'm having difficulty understanding how I need to struction my newx input for predictions using glmnet. @MrFlick – kathystehl Mar 02 '16 at 03:17
  • It would be much easier to help with a reproducible example. Include some sample input data, the code you used to fit the model, and the code you've used to try to predict into new data. – MrFlick Mar 02 '16 at 03:30

0 Answers0