How to guess initialization parameters for non-linear curve fitting with nlinfit?

6 vues (au cours des 30 derniers jours)
I'm trying to use fit the data using this equation:
gaussFit = @(beta, stepFit) (beta(1).*(( ((stepFit./beta(2)).^4)/(1+((stepFit./beta(2)).^4))).*exp((-1).*(stepFit./beta(3))).*cos( (((2*pi).*stepFit)./beta(4)) + beta(5))));
initials = [-0.000006, 0.07, 0.06, 0.12, 0.15];
coeffs = lsqcurvefit(gaussFit, initials, stepFit, avgSPResp2);
(Data attached)
But it is giving me a staight line (which I'm guessing is because the initials are way off compared to the actual fit parameters. However, I've tried to estimate the parameters as much as possible looking at the data.
How do I address this issue?
Thanks!
  3 commentaires
Aindrila Saha
Aindrila Saha le 28 Fév 2020
beta(2) and beta(3) were based on some experimental guesses, the rest were used based on previously done fitting to similar data.
Matt J
Matt J le 28 Fév 2020
Modifié(e) : Matt J le 28 Fév 2020
I am also curious to know why you call your model function "gaussFit", when it does not look at all like a Gaussian model.

Connectez-vous pour commenter.

Réponse acceptée

Alex Sha
Alex Sha le 27 Fév 2020
Hi, Aindrila, guessing the initial start value is always a difficult task since the local optimization algorithms are adopted in most of curve fitting tool or commond,i.e. lsqcurvefit, “Luck + experience” is the current approach, or other way you may try is to use some packages which can performance global optimization calculation,refer the result below:
Root of Mean Square Error (RMSE): 0.0688616729634862
Sum of Squared Residual: 8.77731243616407
Correlation Coef. (R): 0.993270819763553
R-Square: 0.98658692139376
Adjusted R-Square: 0.986572405074922
Determination Coef. (DC): 0.9865195863016
Chi-Square: -3.03449530351813
F-Statistic: 34240.770055333
Parameter Best Estimate
---------- -------------
beta1 308.324915419002
beta2 -0.233165245624372
beta3 0.0481053716827587
beta4 0.351440892233252
beta5 -0.634236150207208
  1 commentaire
Aindrila Saha
Aindrila Saha le 28 Fév 2020
Thank you. Which package did you use for the global optimization calculation?

Connectez-vous pour commenter.

Plus de réponses (1)

Matt J
Matt J le 28 Fév 2020
Modifié(e) : Matt J le 28 Fév 2020
Maybe by doing a Gaussian fit first, it would be easier to guess what the beta(i) parameters should be. You can do a Gaussian fit using gaussfitn (Download).
params=gaussfitn(stepFit,avgSPResp2);
[D,A,mu,sig]=deal(params{:})
z=@(x) D + A*exp( -0.5 * (x-mu).' * inv(sig) *(x-mu) );
hold on
xlims=[min(stepFit),max(stepFit)];
plot(stepFit,avgSPResp2,'ro')
fplot(z,xlims,'Color','k')
xlabel 'stepFit'
ylabel 'avgSPRResp2'
hold off

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by