Automatic Best Curve Fitting
Show older comments
I want to fit the best curve to my data. Everytime I have to do a trial and error method to see what fits (i.e it could be any degree of polynomial). Is there any automatic way to do this as I need to do on 100s of data set individually?
Thanks!!
Accepted Answer
More Answers (2)
Star Strider
on 23 Aug 2012
Edited: Star Strider
on 23 Aug 2012
0 votes
How do you define ‘best curve’? If you’re doing it from a statistical perspective, look in the polyfit documentation for information on calculating the covariance matrix and the 95% confidence intervals on the parameters. As a general rule, the confidence interval for a particular parameter that include zero means that parameter is not necessary in the model. So the ‘best’ polynomial models are those with all parameter confidence intervals in the model not including zero, meaning that all parameters are significantly different than zero. That could be a polynomial of a much lower degree than length(data)-1. It may not fit as well but it will at least have statistical validity, if that is a consideration.
Greg Heath
on 23 Aug 2012
0 votes
It is not clear whether you want
1. To fit the sampled data containing noise and measurement error as closely as possible
or
2. To fit a larger population of data containing noise and measurement error from which the sampled data is considered to be representative.
For example, consider a sample of N = 20 points from a contaminated linear model
y = a*x + b + c*randn(1,N).
The sample data can be represented exactly by a 19th order polynomial with Np = 20 estimated coefficients. However, that polynomial is usually not a good represenative model for the population.
In the latter case functions like STEPWISE and STEPWISEFIT that can automatically choose a more reasonable polynomial order are more appropriate.
Regardless of the model, it is usually wise to use as few estimated parameters, Np, as possible to increase the confidence in the parameter estimates (Search Occam's Razor). A useful rule of thumb is to assume N > Np is necessary and N >> Np is sufficient.
In the case of nonlinear neural network models, trial and error is a relatively straightforward approach. However, more advanced techniques like regularization and validation set stopping tend to be used by frequent practicioners.
Hope this helps.
Greg
2 Comments
Swathi
on 23 Aug 2012
Greg Heath
on 26 Aug 2012
My point is if the sample is sufficient, the model will work on the entire population without further adjustments.
Hope this helps.
Greg
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!