Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logisticRidge predict #16

Closed
msundara1001 opened this issue Feb 12, 2022 · 3 comments
Closed

logisticRidge predict #16

msundara1001 opened this issue Feb 12, 2022 · 3 comments

Comments

@msundara1001
Copy link

Hello,
I am using logisticRidge function to ask how my binary variable (0/1) is related to a set of linear predictors. I am writing to ask for clarification on the ‘predict’ portion of the model.

After fitting a logisticRidge model, I am trying to use the predict function to get fitted probabilities of outcome. However, I appear to be getting different values when I use ‘predict’ and ‘predict’ but supplying the original data that I fitted the model to as new data:

data(mtcars)
library(ridge)
model<-logisticRidge(vs~.,data=mtcars)
predict(model,type="response")
predict(model,type="response",newdata=mtcars[,-8])

Which usage of predict provides accurate values?

I have tested this out on a several datasets and with different combinations of binary predictors and continuous predictors. They seem to produce the same mismatches in predict values. I am happy to provide more replicable examples if you would like me to.

Thank you for your time!

@msundara1001
Copy link
Author

msundara1001 commented Feb 18, 2022

Form writing my own function, I recognize that predict with new data being supplied is providing correct answers.
I did want to ask as a follow up though: glmnet provides slightly different coefficients when compared to ridge for the same lambda values and dataset. That is to be expected though correct?
Thank you for your time!

@SteffenMoritz
Copy link
Owner

SteffenMoritz commented Feb 21, 2022

Hello, Sundaram

thank your for opening an issue. Sorry for the late reply, I've been really busy last week.

This was indeed a bug for logistic ridge (linearRidge didn't have the issue). As you already found out, the results from predict(model,type="response",newdata=mtcars[,-8]) are the correct ones.

I guess, predict() without specifying newdata is used extremly seldom, thus nobody recognized until now.
Really important to open an issue, you probably saved others from getting wrong results.

I uploaded an update to Github and submitted a fixed version to CRAN.

Use this to install the new version from Github:

library(devtools)
install_github("SteffenMoritz/imputeTS")

Should only be a few days, till the new version is also available via CRAN (install.packages)

@SteffenMoritz
Copy link
Owner

Closed - the error is fixed now :)
Thanks a lot for opening the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants