lsqnonlin and stretched exponential function

조회 수: 6 (최근 30일)
Alessandro
Alessandro 2020년 3월 29일
댓글: Torsten 2020년 3월 29일
Hi all,
I am currrently trying to fit my data with lsqnonlin instead lsqcurvefit for a comparative reason and I am facing some troubles.
Starting with the easiest example in https://se.mathworks.com/help/optim/ug/lsqnonlin.html, I modify the function as:
fun = @(r) r(1).*exp(-d.*r(2)).^r(3)-y
This function yields x = [1.0376 3.1962 0.4104].
From here, I calculate my errors in the way:
[x,resnorm,residual,exitflag,output,lambda,J] = lsqnonlin(fun,x0);
N = length(y(:,1));
[Q,R] = qr(J,0);
mse = sum(abs(residual).^2)/(size(J,1)-size(J,2));
Rinv = inv(R);
Sigma_var = Rinv*Rinv'*mse;
x_er = full(sqrt(diag(Sigma_var)));
Here, the values I get are not making any sense to me x_er = [0.02701 6458034.8422 829226.8633]; especially for x(2) and x(3).
Fit and errors are totally fine if I fit similar data in the form: (i) r(1).*exp(-d.*r(2)) or (ii) r(1).*exp(-d.*r(2))+r(3).*exp(-d.*r(4));
Could you please help me? Am I missing something?
Thanks a lot.
Best wishes
Alessandro
  댓글 수: 4
Ameer Hamza
Ameer Hamza 2020년 3월 29일
You code seems to give correct output
Alessandro
Alessandro 2020년 3월 29일
Yes, indeed but I need the errors as well.
When I insert the exponent in the function, i.e., r(3), something goes extremely wrong.
Any idea?

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2020년 3월 29일
편집: Torsten 2020년 3월 29일
error_bounds = nlparci(x,residual,'jacobian',J)
after the call to lsqnonlin.
If you don't have a toolbox with nlparci, search the web for nlparci.m.
  댓글 수: 8
Alessandro
Alessandro 2020년 3월 29일
Thanks. Right but I still don't get why the errors I got are making no sense to me
Torsten
Torsten 2020년 3월 29일
There is no such thing as confidence intervals for dependent parameters.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by