I am trying to use InterpolatingPolynomial to fit a polynomial to a given set of points representing a relationship between two variables. I would like to find a measure between 0 and 1 of how much the polynomial represents the points, 1 being a perfect fit. Consequently, the measure will reflect a polynomial relationship between the two points. I am not sure how to extract this measure from the polynomial. Any ideas are appreciated.
Asked
Active
Viewed 90 times
0
1 Answers
1
While polynomial models fit in Mathematica can be relatively easy to transfer to other languages, you might want to consider a more modern method such as @AntonAntonov 's
Quantile Regression package. (It would be very nice if Mathematica offered additional nonparametric regression functions such as generalized additive models.)
If you really have to have a polynomial with just enough terms to obtain a desired fit, you should consider something like the following approach:
- Set some value for a desired root mean square error. This is the standard deviation for a single observation.
- Try multiple models where you calculate
AICcfor each polynomial model. (If the output ofLinearModelFitorNonlinearModelFitisnlm, then you getAICcwithnlm["AICc"].) - Choose the model with the smallest
AICc. - If the best model has a root mean square error smaller than what you set for the desired root mean square error, then you're done.
The above model selection process is not the best or most consistent way to go. So asking this question on CrossValidated is recommended then implementing that advice in Mathematica.
JimB
- 41,653
- 3
- 48
- 106
InterpolatingPolynomialwill, if possible, find the (likely minimal) polynomial which exactly passes through the provided points. Thus, I'm not sure I understand your question. If you were fitting with a fixed length polynomial (e.g. usingLinearModelFit), then you could use values such asRSquaredorAdjustedRSquaredfor this purpose readily enough. – eyorble Sep 11 '19 at 22:51InterpolatingPolynomialis the best choice though. – Bran Sep 11 '19 at 23:34InterpolatingPolynomialwill add terms until the points are perfectly fit though, since unless two points share the same input value that is always possible. However, it sounds like you want a slightly more constrained polynomial model, and for that I'd recommendLinearModelFitonce again, which already has many goodness-of-fit parameters readily calculable in its model object. – eyorble Sep 11 '19 at 23:43