# R squared for quadratic fitting

thuzhengc12

Mon, 04/12/2021 - 10:30 pm

Hello,

I noticed that R squared seems to be only available for linear fitting, does anyone know how to get R squared for a quadratic fitting? Thank you very much!

Best,

Chu

Hi Chu,

R squared is not valid for nonlinear fitting models. Its not that long ago that I also briefly dealt with this question and I found a few references that might help:

Statistics By Jim. http://statisticsbyjim.com/regression/r-squared-invalid-nonlinear-regression/ (2017, accessed August 17, 2019).Greetings,

Klaus

April 13, 2021 at 12:37 am - Permalink

Hi,

I have previously investigated this topic and one aspect to appreciate is that in a polynomial model from a statistical perspective is not non-linear. The argument being is that what is being fitted is the coefficients and if they do not combine in a term then the equation is linear. The key insight is to focus on the coefficients not the independent parameters.

Y = K

_{0}_{ }+ K1X + K2X^{2 }is linear in the K terms though non-linear in X which is what the scientist is focused on.Y= K

_{0}+ K_{1}X + K_{0}K_{1}X^{2}would be considered non-linear from statistical perspective fitting the K terms.That said there are still concerns with R metric but it could be available. As a side note: JMP statistical package from SAS does return an R statistic from a polynomial fit.

Andy

April 13, 2021 at 06:03 am - Permalink

My take also is that R^2 is also a metric to compare the confidence we can have that data follows one linear model versus the data following a different linear model. The worst abuse that I see most frequently is not when folks use R^2 as a metric fitting non-linear models to data. Rather, the worst abuse is when folks claim that a high value of R^2 in a straight line fit to a set of measured data validates their linear model as the right fit to the data. I shudder every time I see this approach.

April 13, 2021 at 06:20 am - Permalink

In reply to Hi Chu, R squared is not… by Klaus

Thanks all!

April 27, 2021 at 08:39 pm - Permalink

While a quadratic is "linear in the coefficients", which makes the fitting process linear, the function itself is nonlinear, and that's what's important to r^2.

Even fitting a line with the constraint that it pass through zero causes problems with r^2.

April 28, 2021 at 12:07 pm - Permalink