-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstationary_constraint.m
48 lines (48 loc) · 1.3 KB
/
stationary_constraint.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
% constraints of coefficient matrices in mean
% assure that the largest eigenvector of sum(A_i) is inside the unique
% circle
function [c, ceq] = stationary_constraint(parameters, p, q, k, kx, ky)
if ky == 0
para = reshapeparas(parameters, p, q, k);
for i = 1 : q
BEKK(:,:,i) = kron(para.B(:,:,i), para.B(:,:,i));
end
else
para = reshapeparasXY(parameters, p, q, k, kx, ky);
for i = 1 :q
% BEKK(:,:,i) = [kron(para.BX(:,:,i),para.BX(:,:,i));...
% zeros(2*kx*ky,k*k);
% kron(para.BY(:,:,i),para.BY(:,:,i))];
clear temp
clear temp2
temp = [para.BX(:,:,i), zeros(kx,k); zeros(ky,k), para.BY(:,:,i)];
temp2 = kron([eye(k);zeros(k)],[eye(k);zeros(k)]);
temp2 = temp2 + kron([zeros(k);eye(k)],[zeros(k);eye(k)]);
BEKK(:,:,i) = kron(temp, temp) * temp2;
end
end
for i = 1 : p
AR{i} = para.A(:,:,i);
end
Spec = vgxset('AR', AR);
isstable1 = vgxqual(Spec);
sum1 = [0];
for i = 1 : p
sum1 = sum1 + kron(AR{i}', AR{i}');
end
for i = 1 : q
sum1 = sum1 + BEKK(:,:,i);
end
% Spec = vgxset('AR', BEKK);
% isstable2 = vgxqual(Spec);
if abs(eigs(sum1,1)) < 1
isstable2 = 1;
else
isstable2 = 0;
end
if isstable1 && isstable2
c = -1;
else
c = 1000;
end
ceq = [];