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
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.
I am trying to use
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 of
nlm, then you get
- Choose the model with the smallest
- 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.
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. using
LinearModelFit), then you could use values such as
AdjustedRSquaredfor this purpose readily enough. $\endgroup$
InterpolatingPolynomialis the best choice though. $\endgroup$