How do I determine which model fits my data the best?
Show older comments
I am fitting two different curves to a set of data to determine which of them is the better fit. I'm using
myfit1 = fittype('-2^(a.*x+b)+c','coefficients',{'a','b','c'});
fit1 = fit(scantimes,data,myfit1,'StartPoint',[0.005,-2,0.4])
myfit2 = fittype('exp(-d.*x+f)+g','coefficients',{'d','f','g'});
fit2 = fit(scantimes,data,myfit2,'StartPoint',[0.04,1,0])
in a try and catch sequence such that the code is able to compute a fit for each equation. The data will follow one or the other of these patterns, however, I need a way to analyse which is the closer fit. scantimes and data are both just a list of points and I have guessed the start point from observation of data. How would I go about making a comparison between the two fits? Should this use chi squared or is there an easier/better way?
Accepted Answer
More Answers (1)
the cyclist
on 16 Sep 2019
0 votes
The second output from the fit command gives goodness-of-fit statistics.
Categories
Find more on Linear and Nonlinear Regression 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!