Unexplained error using fitdist with Stable distro - help?

I am receiving an unusual error that I can't decode when using fitdist with the 'Stable' distribution option. I've tried troubleshooting by using different datasets and different distributions; the Normal works on the same data. I've used fitdist for stable distributions many times, though not with this release and not in the past 6 months. I've never encountered this error / difficulty before.
The error is:
"Unrecognized function or variable 'getIpOptions'.
Error in fmincon (line 832)
options = getIpOptions(options,sizes.nVar,mEq,flags.constr,defaultopt,10,0.01);
Error in prob.StableDistribution>stablefit (line 1318)
[parmhat,~,err,output] = fmincon(@(params)stable_nloglf(x,params),phi0, ...
Error in prob.StableDistribution.fit (line 211)
params = stablefit(x,0.05,opt);
Error in fitdist>localfit (line 245)
pd = feval(fitter,x,'cens',c,'freq',f,varargin{:});
Error in fitdist (line 192)
pd = localfit(dist,fitter,x,cens,freq,args{:});"
Code that works is:
load hospital;
z = hospital.Weights;
pd = fitdist (z,'Normal');
This generates the error:
pd2 = fitdist(z,'Stable');
Is this a bug in r2020a? I have a copy of Nolan's stablefit toolbox and it fits the same data without throwing an error and with the following result:
>> stablefit(z,1,0)
ans =
2.0000 -0.0214 18.6947 154.0000

1 comentario

I am using R2020a and not getting any error.
>> pd2 = fitdist(z,'Stable');
Warning: Maximum likelihood estimate of the shape parameter ALPHA has converged
to a boundary point.
Confidence intervals and standard errors can not be computed reliably.
> In prob.StableDistribution>stablelike (line 1186)
In prob/StableDistribution/fit (line 212)
In fitdist>localfit (line 245)
In fitdist (line 192)
>> pd2
pd2 =
StableDistribution
Stable distribution
alpha = 2 [0, 2]
beta = 0.988294 [-1, 1]
gam = 18.7061 [0, Inf]
delta = 154.031 [-Inf, Inf]
The solution is also pretty close to your solution from stablefit, except for the beta parameter.

Iniciar sesión para comentar.

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 8 de Abr. de 2020
The error message shows that MATLAB defines a function named stablefit internally for its own use. The definition of stablefit from Nolan's toolbox is also on MATLAB's path. This confuses the MATLAB and MATLAB seems to call the wrong stablefit function. Remove stablefit from Nolan's toolbox from MATLAB's path, and it will probably work fine.

13 comentarios

Hi Ameer, thank you for your help!
So I see your point on the error messages and how that would seem to be the problem.
But I "installed" Nolan's toolbox for troubleshooting after I first encountered the error.
Additionally, I went into Nolan's toolbox and renamed stablefit to stablefitN and ran the following test. Same error statement.
>> pd2 = fitdist(z,'Stable');
Unrecognized function or variable 'getIpOptions'.
Error in fmincon (line 832)
options = getIpOptions(options,sizes.nVar,mEq,flags.constr,defaultopt,10,0.01);
Error in prob.StableDistribution>stablefit (line 1318)
[parmhat,~,err,output] = fmincon(@(params)stable_nloglf(x,params),phi0, ...
Error in prob.StableDistribution.fit (line 211)
params = stablefit(x,0.05,opt);
Error in fitdist>localfit (line 245)
pd = feval(fitter,x,'cens',c,'freq',f,varargin{:});
Error in fitdist (line 192)
pd = localfit(dist,fitter,x,cens,freq,args{:});
>> stablefit(z);
Unrecognized function or variable 'stablefit'.
Did you mean:
>> stablefitN(z);
A search of my MATLAB directory as well as my localuser directory for other "stablefit" conflicts doesn't identify any other files with that name.
Ameer Hamza
Ameer Hamza el 8 de Abr. de 2020
Editada: Ameer Hamza el 8 de Abr. de 2020
Ok. The error seems to be something else, as the first line of error indicates that MATLAB cannot find the function getIpOptions. Can you see whether it exist by entering
which getIpOptions
It is confirmed that I have getIpOptions . I don't have Simulink installed, so I can't use where ... will work on that.
Sorry, I meant which getIpOptions. If you already have it, is it on MATLAB's path. Can you call it from command line. From the error message, it appears that the MATLAB cannot find this file on its path.
Hmm...I can find the file in my MATLAB directory using Windows search. But as you suggest, it isn't in the path:
>>which getIpOptions
'getIpOptions' not found.
After adding to the path, I still have issues with using the 'Stable' option.
>> which getIpOptions
C:\Program Files\MATLAB\R2020a\mcr\toolbox\optim\optim\getIpOptions.m
>> load hospital;
>> x = hospital.Weight;
>> pd = fitdist(x,'Stable');
Error: File: getIpOptions.m Line: 1 Column: 24
Invalid text character. Check for unsupported symbol, invisible character, or pasting of non-ASCII characters.
Error in fmincon (line 832)
options = getIpOptions(options,sizes.nVar,mEq,flags.constr,defaultopt,10,0.01);
Error in prob.StableDistribution>stablefit (line 1318)
[parmhat,~,err,output] = fmincon(@(params)stable_nloglf(x,params),phi0, ...
Error in prob.StableDistribution.fit (line 211)
params = stablefit(x,0.05,opt);
Error in fitdist>localfit (line 245)
pd = feval(fitter,x,'cens',c,'freq',f,varargin{:});
Error in fitdist (line 192)
pd = localfit(dist,fitter,x,cens,freq,args{:});
>> pd2 = fitdist(x,'Normal')
pd2 =
NormalDistribution
Normal distribution
mu = 154 [148.728, 159.272]
sigma = 26.5714 [23.3299, 30.8674]
Maybe I'll work on reinstalling tomorrow. Thanks for your continuing help!
This indicates that there is a character encoding issue in the first line of the file getIpOptions. Can you paste the first line of the file here?
Notice the mcr reference. You have an encoded version of getIPOptions.m for run-time use.
It looks to me as if you need the Optimization Toolbox to use that code.
Hi Walter,
As far as I can tell I have the Optimization Toolbox installed:
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.8.0.1323502 (R2020a)
MATLAB License Number: 827417
Operating System: Microsoft Windows 10 Enterprise Version 10.0 (Build 17763)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 9.8 (R2020a)
Simulink Version 10.1 (R2020a)
Communications Toolbox Version 7.3 (R2020a)
Computer Vision Toolbox Version 9.2 (R2020a)
Curve Fitting Toolbox Version 3.5.11 (R2020a)
DSP System Toolbox Version 9.10 (R2020a)
Data Acquisition Toolbox Version 4.1 (R2020a)
Deep Learning Toolbox Version 14.0 (R2020a)
Image Processing Toolbox Version 11.1 (R2020a)
MATLAB Coder Version 5.0 (R2020a)
MATLAB Compiler Version 8.0 (R2020a)
Optimization Toolbox Version 8.5 (R2020a)
Signal Processing Toolbox Version 8.4 (R2020a)
Spreadsheet Link Version 3.4.3 (R2020a)
Statistics and Machine Learning Toolbox Version 11.7 (R2020a)
Symbolic Math Toolbox Version 8.5 (R2020a)
Wavelet Toolbox Version 5.4 (R2020a)
Ameer, obviously I'm a noob but all the proprietary MATLAB functions are encoded...is there a way for me to get you something useful?
V2MCC8000MEC2000MCR2000á
Then there's a break and the rest of it won't paste. The amount of the first line I can fit on my screen is in the attached PNG (it doesn't display so I'm not sure if it will work)
You should not have any "mcr" directories on your MATLAB path for interactive use.
You need to reinstall the Optimization Toolbox
Chad, the m files are not encoded by default. For example, I am using R2020a and I see the following function signature
function options = getIpOptions(options,nVar,mEq,nonlconflag,defaultopt,defaultHessMemory,defaultPivotThreshold)
and the rest of the code can also be seen. As Walter mentioned, the file you showed is the run-time version of getIpOptions.m. The correct file should be located at C:\Program Files\MATLAB\R2020a\toolbox\optim\optim\getIpOptions.m. If that file is not present, then you should try to reinstall the MATLAB.
Ameer, Walter,
Remove -> Reinstall was the key. All good now; thank you for teaching me about the potential complications with mcr files.
>> pd2 = fitdist(x,'Stable');
Warning: Maximum likelihood estimate of the shape parameter ALPHA has converged to a boundary point.
Confidence intervals and standard errors can not be computed reliably.
> In prob.StableDistribution>stablelike (line 1186)
In prob/StableDistribution/fit (line 212)
In fitdist>localfit (line 245)
In fitdist (line 192)
>> pd2
pd2 =
StableDistribution
Stable distribution
alpha = 2 [0, 2]
beta = 0.9883 [-1, 1]
gam = 18.7061 [0, Inf]
delta = 154.031 [-Inf, Inf]
Glad to be of help.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2020a

Preguntada:

el 8 de Abr. de 2020

Comentada:

el 9 de Abr. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by