How to fit data against another data?
10 views (last 30 days)
Show older comments
I am quite new to MatLab, and now I have two sets of data, the first set is the experimental data, and the second set is the theoretical expectation data. Now I want to do a least-square regression to see how well the data fits with a weighted index of uncertainties for the experimental data, and I also want to see the residual plots. How exactly should I do that? (both data have same x values but differnt y values)
0 Comments
Answers (2)
Star Strider
on 29 May 2014
It seems as though you’ve already done the fit, since you have the theoretical prediction based on your chosen parameters. If you simply want to compare the probability that the observed and calculated data are not statistically different from each other, I suggest a paired-sample ttest. (The t-test doesn’t allow any sort of weighting because that’s not its design.)
If you want to estimate the parameters of the experimental data, using as your regression function the function you used to calculate your theoretical values, and want to do a weighted nonlinear regression, code your function in a form the nonlinear solvers can use, then use nlinfit. (See the section on Nonlinear Regression Using Observation Weights under Examples.) Get all the output from nlinfit, because you may want to test the probability that the estimated parameters are different from the parameters you used in your theoretical calculations. The values nlparci returns are the confidence limits of the parameters and intended to test the hypothesis that the confidence limits are statistically different from zero. If you want to test the probability that the estimated parameters are different from your hypothesized parameters, you will likely have to program that yourself. (I’ve never done that, but I see no reason from a statistical perspective that it would not be a valid test.)
0 Comments
Image Analyst
on 29 May 2014
Edited: Image Analyst
on 29 May 2014
See my demo of polyfit, attached.
You'll find it trivial to add 4 or 5 lines to the existing demo to subtract the fitted and sample (noisy) data from some theoretically perfect data and plot those residuals.
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!