How to make glmnet give the same results as glm?

What parameterization to glmnet will give the same results as glm? (I’m mainly interested in logistic and linear regressions, if that matters.)

Answer

You will get the same results as glm when you pass alpha=1 (the default) and lambda=0. especially that last one: it means no penalization.

Note that the method of fitting is different in both, so although theoretically you should get the same result, there may still be tiny differences depending on your data.

Attribution
Source : Link , Question Author : Yang , Answer Author : Nick Sabbe

Leave a Comment