Why are the estimated coefficients returned by NLINFIT all the same?

2 views (last 30 days)
Drew L
Drew L on 24 Aug 2016
Commented: the cyclist on 24 Aug 2016
I am performing a nonlinear regression to determine the best fit coefficients for a t^1/2 plot that becomes linear after a certain time (x). I want to find the best estimate for time.
When I input my initial guesses into nlinfit, nlinfit returns coefficients which are all the same. I cannot figure out why. I would ideally like to have a unique estimate for all my initial guesses so I can find the minimum misfit coefficient. Having non-unique estimates prevents me from doing this.
Help?
t_t = [75:0.5:85]; % Ma -- Age at which slop switches
m1 = 300; % m/Ma -- slope before t-t
m2 = 0.825; % 0.825 (best by forward model) m/Ma -- slope after t-t
b1 = 3000; % m -- y-intercept before t-t
% Anonymous function
test_fcn = @ (coef,t) (coef(2)*sqrt(t) + coef(3)).*(t <= coef(1)) + ( coef(4) *(t) + (m1*sqrt(coef(1)) + b1)).*(t > coef(1));
M = zeros(length(t_t),9);
for i = 1:length(t_t);
% Make matrix of guesses
guess = [t_t(i) m1 b1 m2]
% Run nlinfit
fit = nlinfit(age,depth,test_fcn, guess);
% Store fit values in matrix
sfit = [fit(1) fit(2) fit(3) fit(4)];
% Calculate yfit using anonymous function
depth_fit = test_fcn(sfit,age);
% Calculate the goodness of fit for these parameters
misfit = sum((abs(depth - depth_fit)).^2);
% Store everything in a matrix
M(i,1:9) = [guess(1:4) sfit(1:4) misfit(1)];
end
My initial guesses:
75
75.5
76
76.5
77
77.5
78
78.5
79
79.5
80
80.5
81
81.5
82
82.5
83
83.5
84
84.5
85
NLINFIT estimated Coefficients
73.8342585833035
73.8342585765359
79.9997047357170
79.9995763838739
79.9995991045945
79.9995531864376
79.9995871290049
79.9997041272140
79.9995740570344
79.9996143251319
79.9995155307410
79.9996903874223
79.9996050266437
79.9995910209715
79.9995429091664
79.9995538921889
79.9995486637682
79.9995813685956
79.9995991398304
79.9995677153829
79.9996795763662
  1 Comment
the cyclist
the cyclist on 24 Aug 2016
Unless I missed something, we can't run your code because we do not have the age and depth variables defined.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!