1
$\begingroup$

I am using R glmnet function for the elastic net for logistic regression with binary outcome and would like to calculate the R-square value.

I am getting different results when I use the dev.ratio from the glmnet and when applying the formula found here: https://stackoverflow.com/questions/50610895/how-to-calculate-r-squared-value-for-lasso-regression-using-glmnet-in-r

    cvfit = cv.glmnet(x, y, family = "binomial", type.measure = "class")
    rsq = 1 - cvfit$cvm/var(y)
plot(cvfit$lambda,rsq)

From the glmnet documentation:

dev.ratio = The fraction of (null) deviance explained (for "elnet", this is the R-square). The deviance calculations incorporate weights if present in the model. The de- viance is defined to be 2*(loglike_sat - loglike), where loglike_sat is the log- likelihood for the saturated model (a model with a free parameter per observa- tion). Hence dev.ratio=1-dev/nulldev.

Obviously, formulas are different, any experiences? What would be the correct way for the logistic regression with the elastic net?

Thank you

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.