

You could fix that with a spline, a cubic natural spline will control the derivative at xmin and xmax, but to do that, you should sort your dataset (x axis) and take a subsample of the n points with rolling average as control points to the spline algoritm.

Polynoms are not good for extrapolation, once there are no control points outside your domain. In the fitted line plot, the nonlinear relationship follows the data almost exactly. Let's say your domain is, an 8th order polynom is good for interpolation, but it wiggles because of the high order and also because the point density is oddly distributed. Comparing the Regression Models and Making a Choice. So the big takeaway here is that the tools of linear regression can be useful even when the underlying relationship between x and y are non-linear and the way that we do that is by transforming the data. the x-values should be the most boring scatterplot you’ve ever seen. To prove linearity A scatterplot of the residuals vs. If you want a nonlinear regression you need a different function such as nls (). You could create x2 <- x2 and then regress y x2 and plot that in (y,x2) space. If the residuals have a curved pattern then it is NOT linear. Thats just it: you are fitting a linear model over a nonlinear transformation of your variables. You must look at the scatter plot AND you must look at the residual pattern it makes. from your plot of n (x,y) points, they are linked with straight lines if you display points instead, should see the points density along your domain, and it's not evenly distributed as the lines are not. Sometimes a high r value for linear regression is deceptive. There are some possible issues with your data set.
