Solved – Why, when I scale the data set, glmnet gives error

glmnetmachine learningregression

I'm using glmnet for building the regression models.
My data are already log-transformed. when I scale my data set (zero mean, and SD=1), I get the following error:

Error in elnet(x, is.sparse, ix, jx, y, weights, offset, type.gaussian,  : 
  NA/NaN/Inf in foreign function call (arg 5)

But without scaling data, glmnet run perfectly.
would someone help me to understand why this happens?

Best Answer

You most likely have NaN in your scaled data due to scaling of some columns with constant values (dividing by SD of zero), check the scaled data with is.na().

Related Question