There are many libraries in R and python for doing orthogonal distance regression and for doing ridge regression separately. Is there one for doing them at the same time?


I don't know about R but for python I use scipy.odr for orthogonal distance regression


and for Ridge Regression I tend to use sklearn.linear_model.Ridge


And when I want it together then I use both of the code from the above repo and make my own custom function.

Hope it might help you!

| cite | improve this answer | |
  • $\begingroup$ I really don't think it's possible to simply combine them in a custom function. The problem is that to use ridge regression you need to change the objective function of the optimization. But in this case the objective function is hardcoded in the FORTRAN library that scipy.odr calls. If you can show me otherwise however then I will absolutely accept the answer and award the bounty. $\endgroup$ – rhombidodecahedron Nov 18 '19 at 0:08
  • $\begingroup$ gist.github.com/rhanguha/feedfa45043a3485a8b3a9dbccab1df5 This is the code I use for ODR. Please check if this helps you out or not else I will try to update the code. I thought of writing the ODR from scratch to incorporate your ideas. $\endgroup$ – Rehan Guha Nov 18 '19 at 4:24
  • $\begingroup$ Hi @Rehan Guha, as this code relies on the FORTRAN ODRPACK package for the ODR calculation, it is not possible to modify it to include a ridge penalty without rewriting the underlying FORTRAN code. I think the ODR calculation would need to be rewritten into Python in order to incorporate the ridge penalty. $\endgroup$ – rhombidodecahedron Nov 18 '19 at 4:35
  • 1
    $\begingroup$ @rhombidodecahedron Planning to do so. Will update if I get time to convert the code to Python. $\endgroup$ – Rehan Guha Nov 18 '19 at 4:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.