Creating a loop for mle() function for 'tLocationScale' fit

Hello, my plroblem is the following. I have a vector of returns that has length of 4475. I want to create a moving window of 250 observations, so that for each pack of 250 observations I could use a function mle(data,'distribution','tLocationScale); to estimate distribution. But what is crucial for me is to extract vector of degrees of freedom. In a simple version i have:
parameters_data=mle(data,'distribution','tlocationscale');
degrees_of_freedom = parameters_data(3);
if degrees_of_freedom > 3
dof=degrees_of_freedom;
else
dof=3
end.
For a version that I wanted to do I used
N = 4475;
l= 250;
parameters_data=zeros(N-l+1,3);
for t = 1:(N-l+1)
parameters_data(t,:)=mle(data(t:(t+l-1)),'distribution','tlocationscale');
end
But I have the following message "Warning: Maximum likelihood estimation did not converge. Iteration limit exceeded. > In tLocationScaleDistribution>tlsfit at 323 In tLocationScaleDistribution>tLocationScaleDistribution.fit at 177 In fitdist>localfit at 231 In fitdist at 178 In mle at 374 In Untitled at 113 "
Can someone advice me how should I change it so it would work correctly? Thank you in advance!

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by