Regression Technique Gives Bad Coefficients
3 views (last 30 days)
Show older comments
I'm trying to perform an unfolding technique using regression techniques, and to be blunt, my abilities with matlab and with regression techniques in general is basic at best. I've tried using the lsqcurvefit command, but I'm running into one problem. When doing a fit of an equation such that Y=x1A1+x2A2+...xnAn, where A are data sets and Y is the response I'm trying to fit the summation to, Matlab is unwilling to return only positive coefficients. I've tried setting the lower and even upper bounds, as well as using the options=optimset but this does not seem to help. Instead of returning coefficients which makes sense, matlab will spit out several identical values with an e-14 magnitude and produce one or two spikes. If the lower bounds are not set to require that x be greater than or equal to 0. Can anyone suggest a fix for this, or am I just hitting my head against a wall here?
Example of the code I'm trying to get working, it was based on what I found in the help manual as well as examples online.
MDS_X = @(z_X,xdata_X)(z_X(1)*A0_121+z_X(2)*A0_167+z_X(3)*A0_217+z_X(4)*A0_293+z_X(5)*A0_360);
z0 = ones(1,5);
options = optimset('MaxIter',10,'Tolfun',1e-10)
[z_X,resnorm_X,residual_X] = lsqcurvefit(MDS_X,z0,t0_121,LR_C_PuBe,zeros(1,5),ones(1,5),options);
0 Comments
Answers (1)
Star Strider
on 11 Nov 2014
I’m slightly lost. I understand that your anonymous function:
MDS_X = @(z_X,xdata_X)(z_X(1)*A0_121+z_X(2)*A0_167+z_X(3)*A0_217+z_X(4)*A0_293+z_X(5)*A0_360);
picks up ‘A0_121’ and the other from your workspace, but where do you use your independent variable values, ‘xdata_X’? Your equation doesn’t seem to be a function of it, and that could be causing problems for lsqcurvefit, that is doing it best to fit your dependent variable to a function of your independent variable.
12 Comments
Star Strider
on 12 Nov 2014
I’m still not understanding what you’re doing, but if lsqcurvefit gives the best results, go with it.
I don’t understand your regression objective function, because it does not seem to be a function of ‘xdata_X’, and lsqcurvefit is calculating your ‘z_X’ parameters as though it is.
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!