0

I run this code in matlab to minimize the parameters of my function real_egarchpartial with fminsearch:

data = xlsread('return_cc_in.xlsx');
SPY = data(:,25);

    dailyrange = xlsread('DR_in.xlsx');
    drSPY= dailyrange(:,28);
    startingVals = [mean(SPY); 0.041246; 0.70121; 0.05; 0.04; 0.45068; -0.1799; 1.0375; 0.06781; 0.070518];
    T = size(SPY,1);

    options = optimset('fminsearch');
    options.Display = 'iter';

    estimates = fminsearch(@real_egarchpartial, startingVals, options, SPY, drSPY);

    [ll, lls, u]=real_egarchpartial(estimates, SPY, drSPY);

And I get this message:

Exiting: Maximum number of function evaluations has been exceeded
         - increase MaxFunEvals option. 

I put the original starting values. So I assumed they are corrects. I used fminsearch and not fmincon because my function hasn't constraints and with fminunc my function gets a lot of red messages. the real_egarchpartial function is the following:

function [ll,lls,lh] = real_egarchpartial(parameters, data, x_rk)
mu = parameters(1);
omega = parameters(2);
beta = parameters(3);
tau1 = parameters(4);
tau2 = parameters(5);
gamma = parameters(6);
csi = parameters(7);
phi = parameters(8);
delta1 = parameters(9);
delta2 = parameters(10);

%Data and h are T by 1 vectors
T = size(data,1);
eps = data-mu;
lh = zeros(T,1);
h = zeros(T,1);
u = zeros(T,1);

%Must use a back Cast to start the algorithm
h(1)=var(data);
lh(1) = log(h(1));
z= eps/sqrt(h(1));
u(1) = rand(1);

lxRK = log(x_rk);
for t = 2:T;
   lh(t) = omega + beta*lh(t-1) + tau1*z(t-1) + tau2*((z(t-1).^2)-1)+ gamma*u(t-1);
   h(t)=exp(lh(t));
   z = eps/sqrt(h(t));
end
for t = 2:T
    u(t)= lxRK(t) - csi - phi*h(t) - delta1*z(t) - delta2*((z(t).^2)-1);
end 
lls = 0.5*(log(2*pi) + lh + eps.^2./h);
ll = sum(lls);

Could someone explain what is wrong? Is there another function more efficient for my estimation? Any help will be appreciated! Thank you.

  • I could not understand you problem . If it that `exit` message then that is because you have set `MaxFunEvals` to `100` so `real_egarchpartial` is evaluated only `100` times and then `fminunc` terminates displaying the `exit message` as the reason for its termination . – Nishant Jun 28 '14 at 09:49
  • @Nishant I'm sorry I made a mistake in the code. I'm using fminsearch and I don't want to set MaxFunEvals. That was an attempt to see what in the function changes, because I got the message about MaxFunEvals that I wrote in the question above. My problem is that the estimated values are different from my reference paper and maybe because the options of fminsearch aren't setted in the correct way. – user3553802 Jun 28 '14 at 10:22

0 Answers0