# Fitting a Custom Sigmoid

42 views (last 30 days)
Jane Kelleher on 26 Aug 2020
Commented: Alex Sha on 27 Aug 2020
Hello,
I have a set of data that decays in a sigmoidal fashion. I believe it should be a good fit to a function of the form shown in the first screenshot, but when I use the Custom Fit feature in the Curvefitting App matlab gives a -Rsq so something is clearly going wrong. I have attached a screenshot of the attempted fit and result as well. I would really appreciate any advice or input as to why this may not be working and alternatives I could try.
Thank you!
Jane Kelleher on 26 Aug 2020
I also tried adding a plateau for the base, ie: a1 * exp(-a2 .* exp(X)) + a3

Alex Sha on 27 Aug 2020
Hi，if the fitting function is：
1：y=a1*exp(-a2*exp(x))
Root of Mean Square Error (RMSE): 0.291990919479646
Sum of Squared Residual: 2.81353700293277
Correlation Coef. (R): 0.943693599341358
R-Square: 0.890557609437848
Parameter Best Estimate
---------- -------------
a1 7.58840204504645
a2 1.16352684388827E-7
2：y=a1*exp(-a2*exp(x))+a3
Root of Mean Square Error (RMSE): 0.111213914229836
Sum of Squared Residual: 0.408161645704602
Correlation Coef. (R): 0.991993546182226
R-Square: 0.984051195667188
Parameter Best Estimate
---------- -------------
a1 3.31691483854775
a2 6.92191293955397E-7
a3 4.93177045354278
3：y=a1*exp(-a2*exp(a4*x))+a3
Root of Mean Square Error (RMSE): 0.00643423581192002
Sum of Squared Residual: 0.001366179885952
Correlation Coef. (R): 0.999973308091645
R-Square: 0.999946616895747
Parameter Best Estimate
---------- -------------
a1 2.46665608498939
a2 4.05630590375969E-12
a4 1.85195743324274
a3 5.25959927640292
Alex Sha on 27 Aug 2020
Hi, Jane, the above results posted are obtained from another software of "1stOpt". For the fitting function of "y=a1*exp(-a2*exp(a4*x))+a3", it looks simple, but seems to be very difficulty for Matlab, either cftool or lsqcurvefit/nlinfit, to get proper outcomes.

### Community Treasure Hunt

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

Start Hunting!

Translated by