Programmers learn & share
0 votes
749 views

Problem :

I am trying to predict probabilities in a dataset by using glmnet but facing following issue
cholmod error 'x and/or y have wrong dimensions' at file ../matrixops/cholmod_sdmult.c, line 90
by (6.9k points)   | 749 views

1 Answer

0 votes

Solution :

It seems you just have wrongly thing assigned to newx. Instead of:

bank$rich <- NULL newx = data.matrix(test$rich)

I guess you need to null out the values in test$rich and then need to feed test to data.matrix. So something like below: 

test$rich <- NULL newx = data.matrix(test) ridge.pred=predict(ridge.mod,newx=newx) 

It worked for me.

Also i think your original data frame has some patterns based on the row: so rows after 200 have NA values in newAccount. So you may want to address missing values and your train/test split before your regression.

by (36.1k points)  
2,245 questions
2,807 answers
60 comments
241 users