Improving fit of custom function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi everyone,
I would like to fit a dataset to a custom equation. Equation:
![function_lab.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/219505/function_lab.png)
I used cftool and chose custom equation and specified the function: A+m*x+(B+n*x)/(1+10^-[(x-C)/D]) :
![Q1.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/219506/Q1.png)
How can I improve the fit? In paricular I would like the beginning of the curve to follow the data points much better. I am sure there are better functions to fit this dataset to, but I require to use the equation given to analyze and extract parameters C and D in particular.
I have attached the data in a .txt file.
Appreciate any help!
0 comentarios
Respuestas (2)
Rajendra Gupta
el 27 de Mayo de 2020
Alex Shaw's parameter determination for this problem is very different from what 'mz86' obtained from the Matlab curve fitting tool. Why is it so? I too find problems in fitting my custom equations that involve integrals. Also, Alex Shaw only provides the parameters, not the 95% confidence bounds for each parameters. What is the difference in the two approaches that yield drastically different parameters for fitting the same data using the same equation? How can I replicate the fits and parameter results obtained by Alex so that I could try to implement the same approach to my curve fitting problem?
Your early response will be gratefully appreciated.
Thank you.
Here is one of my custom equation to fit 1048 data points with errors. Excel data file is attached.
y=VPCexp(x,Om0,299840/H0,a)+5*log10(1+x)+25
function [y] = VPCexp(z,Om0,R0,a)
n = length(z);
y=zeros(size(z));
for i=1:n
zl=z(i);
fun = @(x) (Om0.*((1+x).^3.*exp(a./3.*(1-(1+x).^(-3)))-exp(2.*a./3.*(1-(1+x).^(-3))))+(1+x).^2).^-0.5;
yl = integral(fun,0,zl);
dP=R0*sinh(yl/exp(-a/3*(1-(1+zl)^(-3))));
y(i)= 5*log10(dP);
end
The fit I get is as follows:
General model:
f(x) = VPCexp(x,Om0,299840/H0,a)+5*log10(1+x)+25
Coefficients (with 95% confidence bounds):
H0 = 71.24 (70.47, 72.01)
Om0 = 0.5749 (0.3704, 0.7793)
a = 0.8509 (0.6572, 1.045)
Goodness of fit:
SSE: 1034
R-square: 0.997
Adjusted R-square: 0.997
RMSE: 0.9948
0 comentarios
Alex Sha
el 24 de Mayo de 2019
Hi, what is the function you want to fit?
y= A+m*x+(B+n*x)/(1+10^(-((x-C)/D)))
or
y= A+m*x+(B+n*x)/(1+exp(-((x-C)/D)))
if the former:
Root of Mean Square Error (RMSE): 172.220715864347
Sum of Squared Residual: 5783695.11970149
Correlation Coef. (R): 0.99832342215494
R-Square: 0.996649655223151
Adjusted R-Square: 0.996614755798392
Determination Coef. (DC): 0.996649655223151
Chi-Square: 926.211553161795
F-Statistic: 11244.6209348302
Parameter Best Estimate
---------- -------------
a 11846.2854391282
m 24.3940304694188
b -1.64416859185817E18
n -8.09054974984671E17
c -83.4293845593878
d -5.89360891288855
if the later:
Root of Mean Square Error (RMSE): 172.220715864346
Sum of Squared Residual: 5783695.11970144
Correlation Coef. (R): 0.998323422154939
R-Square: 0.996649655223149
Adjusted R-Square: 0.99661475579839
Determination Coef. (DC): 0.996649655223151
Chi-Square: 926.211451996129
F-Statistic: 11244.6209212544
Parameter Best Estimate
---------- -------------
a 11846.2854211205
m 24.3940307991782
b -6.12857667267666E17
n -3.01572212177201E17
c -80.9034614293268
d -2.55956180987299
![c159.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/220836/c159.jpeg)
0 comentarios
Ver también
Categorías
Más información sobre Fit Postprocessing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!