SteffenMoritz/ridge

logisticRidge predict

Closed this issue · 3 comments

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!

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!

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)

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