Index in position 1 exceeds array bounds (must not exceed 1). FMINCON

1 view (last 30 days)
A Garch model with a Vix as a esogenous variable
Yt = dev.std * Epsilon
Epsilon = Normal or student (0,1)
dev.std^2_t = omega + alpha*r_t-1^2 + Beta*dev.std^2_t-1 + lambda*VIX^2_t-1
i coefficienti omega alpha beta e delta si trovano con la maximum likelihood.
il resto è dato.
global y
filename = 'Dati_daily.xlsx';
xlRange = 'A1:L7420';
[num] = xlsread(filename,xlRange);
Dati
CAC40 =num(:,1);
FTSE100 =num(:,2);
DAX =num(:,3);
FTSEMIB =num(:,4);
SP500 =num(:,5);
NASDAQ =num(:,6);
FTSECHINA =num(:,7);
HANGSENG =num(:,8);
TOPIX =num(:,9);
ASX200 =num(:,10);
VIX =num(:,11);
%
returns_CAC40 = diff(log(CAC40));
returns_FTSE100 = diff(log(FTSE100));
returns_DAX = diff(log(DAX));
returns_FTSEMIB = diff(log(FTSEMIB));
returns_SP500 = diff(log(SP500));
returns_NASDAQ = diff(log(NASDAQ));
returns_FTSECHINA = diff(log(FTSECHINA));
returns_HANGSENG = diff(log(HANGSENG));
returns_TOPIX = diff(log(TOPIX));
returns_ASX200 = diff(log(ASX200));
returns_VIX =diff(log(VIX));
y1=returns_CAC40;
y2=returns_FTSE100;
y3=returns_DAX;
y4=returns_FTSEMIB;
y5=returns_SP500;
y6=returns_NASDAQ;
y7=returns_FTSECHINA;
y8=returns_HANGSENG;
y9=returns_TOPIX;
y10=returns_ASX200;
y11=returns_VIX;
% selezione dati singoli
y = y1;
y(isnan(y))=0;
y11(isnan(y11))=0;
% Creazione modello
[T] = size(y,1);
sigma2 = zeros(T,1);
log_likelihood_i = zeros(T,1);
%% function [log_lik] =log_lk_GARCHVIX(theta)
omega = theta(1,1);
alpha = theta(2,1);
beta = theta(3,1);
delta = theta(4,1);
sigma2(1,1) = omega;
log_likelihood_i(1,1) = -0.5 * log(2*pi) - 0.5* log(sigma2(1,1)) - 0.5/sigma2(1,1)*(y(1,1))^2;
for t = 2 : 1 : T
sigma2(t,1) = omega + alpha * y(t-1,1)^2 + beta * sigma2(t-1,1)^2 + delta * y11(t-1,1)^2;
log_likelihood_i(t,1) = -0.5 * log(2*pi) - 0.5* log(sigma2(t,1)) - 0.5/sigma2(t,1)*(y(t,1))^2;
end
log_lik = -sum(log_likelihood_i);
end
%%
theta0 = [2,0.2,0.1,0.4];
lb = [0.000000001;
0
0
0];
ub = [1000000;
0.999999
0.999999
0.999999];
[x,fval,exitflag,output,lambda,grad,hessian] = fmincon('log_lk_GARCHVIX',theta0,[],[],[],[],lb,ub)
THE ERRORS ARE:
Index in position 1 exceeds array bounds (must not exceed 1).
alpha = theta(2,1);
Error in fmincon (line 562)
initVals.f = feval(funfcn{3},X,varargin{:});
Caused by:
Failure in initial objective function evaluation. FMINCON cannot continue.

Accepted Answer

Matt J
Matt J on 2 Aug 2020
Make theta0 a column vector:
>> theta0 = [2,0.2,0.1,0.4].'
theta0 =
2.0000
0.2000
0.1000
0.4000

More Answers (0)

Categories

Find more on Conditional Variance Models in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!