我试图最小化关于参数 beta0 向量的函数句柄。我的函数使用内置的mvncdf函数,该函数使用正定协方差矩阵。这个矩阵是从参数向量的一部分计算出来的。还有一些参数的绝对值小于1的限制。
我以两种方式将约束设置为fmincon:所需值的上限和下限,并使用以下非线性约束:
function [c,ceq] = pos_def(beta0)
rho_12 = beta0(end-2,1);
rho_13 = beta0(end-1,1);
rho_23 = beta0(end,1);
sigma111=[1 rho_12 rho_13; rho_12 1 rho_23; rho_13 rho_23 1];
sigma110=[1 rho_12 -rho_13; rho_12 1 -rho_23; -rho_13 -rho_23 1];
sigma101=[1 -rho_12 rho_13; -rho_12 1 -rho_23; rho_13 -rho_23 1];
sigma100=[1 -rho_12 -rho_13; -rho_12 1 rho_23; -rho_13 rho_23 1];
eig111 = eig(sigma111);
eig110 = eig(sigma110);
eig101 = eig(sigma101);
eig100 = eig(sigma100);
c = vertcat(-eig111,-eig110,-eig101,-eig100);
由于所有矩阵都是方形的并且通过收缩对称,因此作为正定性的代理,我使用特征值的符号。
优化问题如下:
opts = optimset ('Display','iter','TolX',1e-15,'TolFun',1e-15,...
'Algorithm','interior-point','MaxIter',100000,'MaxFunEvals',1000000);
xc3_3=fmincon(model, beta,[],[],[],[],lb,ub,@pos_def, opts)
但是在估计期间 fmincon 中止错误
使用 mvncdf 时出错(第 193 行) SIGMA 必须是正方形、对称、正定矩阵。
在调试模式下,我可以看到,经过两次评估迭代后,Matlab 尝试估计不满足我的非线性约束的 beta0,
beta0 =
-46.9208
33.2916
-2.1797
-46.4251
3.8337
-0.3066
6.1213
-20.9480
-1.7760
-0.1807
1.3950
4.5348
-0.9838
0.2600
-6.9887
-24.6157
-0.0112
-0.9923
-0.9284
0.7664
0.3062
并且约束 c < 0 不满足:
c =
0.3646
-1.2998
-2.0648
0.3646
-1.2998
-2.0648
0.3646
-1.2998
-2.0648
0.3646
-1.2998
-2.0648
我不明白为什么这个优化工具试图在禁止区域找到解决方案以及如何避免这个问题。或者如何以线性方式设置正定性约束。