Quantcast
Viewing latest article 4
Browse Latest Browse All 11

How to find a perfect regression fit in R?

I have a set of points, which I know can be described with some equation. How can I find this equation?

The scatter plot for this set looks like this:
Image may be NSFW.
Clik here to view.
enter image description here

I look at the plot and assume that I can use a polynomial regression to find the desired curve. Therefore, I right the following code trying a 7th plane curve:

fit <- lm( y~poly(x,7) )

The result looks like:
Image may be NSFW.
Clik here to view.
enter image description here

Then, I plot the absolute values of errors and it appears that they all do not equal to zero and actually reach the value of 0.025. So, despite the plot looks as if the curve fits the dataset, it is apparently not the case. I can of course increase the order of the curve thereby decreasing the values of errors, but I still cannot be sure if any curve will fit the dataset perfectly. Maybe there exists a better way to do find a perfect fit?

Moreover, I tried to find a curve assuming that it is a polynomial one. How can I be sure that it is not a cubic curve or some tricky sinusoidal equation? Should it be learnt only by experience or do I miss some method to determine this?


Viewing latest article 4
Browse Latest Browse All 11

Trending Articles