Borrar filtros
Borrar filtros

Error in copulafit: using chol Matrix must be positive definite.

2 visualizaciones (últimos 30 días)
farshid balaneji
farshid balaneji el 6 de Sept. de 2017
Respondida: Ben Drebing el 12 de Sept. de 2017
I am trying to fit t copula in MatLab to my data and my function is:
u = ksdensity(range_1, range_1,'function','cdf');
v = ksdensity(range_2, range_2,'function','cdf');
%fit a t-copula to returns
rng default ; % For reproducibility
[Rho,nu] = copulafit('t',[u v],'Method','ApproximateML');
And I get an error that says:
Error using chol
Matrix must be positive definite.
Error in copulafit/approxProfileNLL_t (line 314)
nll = negloglike_t(nu,chol(Rho),t_);
Error in copulafit>bracket1D (line 494)
oldnll = nllFun(bound);
Error in copulafit (line 126)
[lowerBnd,upperBnd] = bracket1D(profileFun,lowerBnd,5); % 'upper', search ascending from 5
I understood that it happens due to chol() decomposition, but I don't know which parameters should be changed to overcome this problem. Any help would be appreciated.
data that I use has been attached to this question box.

Respuestas (1)

Ben Drebing
Ben Drebing el 12 de Sept. de 2017
The reason you are getting this error is that your data (range_1 and range_2) is too correlated. You can see this by running the command:
>> scatterhist(range_1, range_2);
The correlation between range_1 and range_2 is too strong for "copulafit". I would recommend trying some other method of fitting your data. However, if you still want to use "copulafit", to get around this error, you can add a little noise to range_1 and range_2.
So, after you load your data, do:
>> range_1 = range_1 + 0.5*(rand(251,1) - 0.5); % This will randomly shift each data point by some
>> range_2 = range_2 + 0.5*(rand(251,1) - 0.5); % random value between -0.25 and 0.25
This will make it so your data isn't exactly linear allowing "copulafit" to fit it.

Categorías

Más información sobre Linear Algebra 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!

Translated by