How to estimate goodness-of-fit using scipy.odr?

orthogonal, regression, scipy

Solution

The `res_var` attribute of the `Output` is the so-called reduced Chi-square value for the fit, a popular choice of goodness-of-fit statistic. It is somewhat problematic for non-linear fitting, though. You can look at the residuals directly (`out.delta` for the `X` residuals and `out.eps` for the `Y` residuals). Implementing a cross-validation or bootstrap method for determining goodness-of-fit, as suggested in the linked paper, is left as an exercise for the reader.

Problem

I am fitting data with weights using scipy.odr but I don't know how to obtain a measure of goodness-of-fit or an R squared. Does anyone have suggestions for how to obtain this measure using the output stored by the function?

Original source