What does this error message mean?

10 vues (au cours des 30 derniers jours)
Matthias
Matthias le 3 Oct 2014
Modifié(e) : Matt J le 6 Oct 2014
I've got two vectors:
times =
0 0.0005 0.0050 0.0500 0.5000 5.0000
mittel =
0 2.0505 5.7940 8.8363 14.1563 35.6821
I would like to fit two functions to these vectors:
func1 = 'y ~ b0*(x + b1)^(1/2)';
fitresult = NonLinearModel.fit(times,mittel,func1,[ 2.775e+06 0.008033 ]);
and
func2 = 'y ~ b0*(x + b1)^(1/3)';
fitresult2 = NonLinearModel.fit(times,mittel,func2,[2.1e+01 0 ]);
The first works absolutly fine, but the second gives me an error I don't understand:
Error using internal.stats.getscheffeparam>ValidateParameters (line 182)
If non-empty, JW must be a numeric, real matrix.
Error in internal.stats.getscheffeparam (line 110)
[J,VF,VP,JW,Intopt,TolSVD,TolE,VQ,usingJ] =
ValidateParameters(J,VF,VP,JW,Intopt,TolSVD,TolE,VQ,allowedIntopt);
Error in nlinfit (line 340)
sch =
internal.stats.getscheffeparam('WeightedJacobian',J(~nans,:),'Intopt','observation','VQ',VQ);
Error in NonLinearModel/fitter (line 1121)
[model.Coefs,~,J_r,model.CoefficientCovariance,model.MSE,model.ErrorModelInfo,~]
= ...
Error in classreg.regr.FitObject/doFit (line 219)
model = fitter(model);
Error in NonLinearModel.fit (line 1484)
model = doFit(model);

Réponses (3)

Sean de Wolski
Sean de Wolski le 3 Oct 2014
For some reason the model is returning an imaginary component. I would contact tech support, that error message is useless.
  2 commentaires
Matt J
Matt J le 3 Oct 2014
Modifié(e) : Matt J le 6 Oct 2014
Probably because (x+b1).^(1/3) is being used instead of nthroot(x+b1,3). E.g.,
>> (-1)^(1/3)
ans =
0.5000 + 0.8660i
>> nthroot(-1,3)
ans =
-1
Sean de Wolski
Sean de Wolski le 6 Oct 2014
Learn something new every day :)

Connectez-vous pour commenter.


Matt J
Matt J le 3 Oct 2014
Modifié(e) : Matt J le 3 Oct 2014
In addition to the need for nthroot(q,3) instead of q^(1/3), your model equations are non-differentiable w.r.t. b1. This makes me wonder if the Jacobian calculations are creating trouble.
I recommend FMINSPLEAS ( Download ) for your problem, since it does not rely on differentiability. Also, it can take advantage of the fact your model is linear w.r.t. b0.
  1 commentaire
Matt J
Matt J le 3 Oct 2014
Modifié(e) : Matt J le 3 Oct 2014
As an example
z=[times(:),ones(numel(times),1)]\mittel(:).^3;
b1start=z(2)./z(1); %starting guess for b1
[b1,b0]=fminspleas( {@(b1,x) nthroot(x + b1, 3)}, b1start, times, mittel)

Connectez-vous pour commenter.


Star Strider
Star Strider le 3 Oct 2014
Modifié(e) : Star Strider le 3 Oct 2014
For whatever reason, nlinfit does not have a problem with either one:
func1 = @(b,x) b(1).*(x + b(2)).^(1/2);
func2 = @(b,x) b(1).*(x + b(2)).^(1/3);
B1 = nlinfit(times, mittel, func1, [ 2.775e+06 0.008033 ])
B2 = nlinfit(times, mittel, func2, [2.1e+01 0 ])
producing:
B1 =
16.2925e+000 47.9075e-003
B2 =
20.5786e+000 -850.3513e-021i 6.1977e-012 +156.4066e-024i
but it returns complex parameter estimates for ‘B2’, although with negligible imaginary components.

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by