再现我的过程要下的代码。
7. Copula toolbox for Matlab, version 1.07, 5apr08( http://econ.duke.edu/~ap172/ )
1. James LeSage's Econometrics Toolbox for Matlab
( http://econ.duke.edu/~ap172/ )->( http://www.spatial-econometrics.com/html/jplv7.zip )
我在尝试运行Andrew Patton's Matlab code 的 Copula toolbox for Matlab,出现fmincon的错误。
我是把“7. Copula toolbox for Matlab, version 1.07, 5apr08” 中的“copula_example_code.m”
的代码一段一段剪切出来尝试运行,但是出现了错,我剪切代码如下:
-------------------------------------------------------------------------------------------
% Example code for some copula functions
%
% Andrew Patton
%
% 27 February 2006
load 'D:\MATLAB7\work\copulas\Patton_copula_toolbox\ibm_ccola_rets.txt' -ascii;
ibm = ibm_ccola_rets(:,1);
ccola = ibm_ccola_rets(:,2);
size(ibm)
size(ccola)
%xycdata = [ibm ccola];
% exceedence correlations
inc = 0.025;
qq = (0.1:inc:0.9)';
qq2 = [(0.1:inc:0.5)';(0.5:inc:0.9)'];
temp1 = ang_chen1(ibm,ccola,qq);
%figure(1),plot(qq2,temp1,'o-')
% quantile dependence
temp2 = quantiledep(ibm,ccola,qq);
%figure(2),plot(qq,temp2,'o-');
% obtaining Unif(0,1) data
% NOTE: for this example I will just use the empirical cdf to transform the
% data, but in practice this is the step where a model for the conditional
% (marginal) densities would be used: conditional means, variances and
% distributions.
u = empiricalcdf(ibm);
v = empiricalcdf(ccola);
size(u)
size(v)
T = length(u)
% dropping the first few so we have an even 2500 observations
u = u(end-2499:end);
v = v(end-2499:end);
T = length(u)
% estimating some copula models
options = optimset('Display','iter','TolCon',10^-12,'TolFun',10^-4,'TolX',10^-6);
% 1. Normal Copula
%kappa1 = corrcoef12(norminv(u),norminv(v))
%LL1 = NormalCopula_CL(kappa1,[u,v])
% 3. Rotated Clayton copula (with tail dep in upper tail instead of lower)
lower = 0.0001;
theta0 = 1;
[ kappa3 LL3] = fmincon('claytonCL',theta0,[],[],[],[],lower,[],[],options,1-[u,v]);
-------------------------------------------------------------------------------------
错误如下:
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 260
In xyc at 56
max Directional First-order
Iter F-count f(x) constraint Step-size derivative optimality Procedure
0 2 289.506 -0.9999
1 5 -0.0421611 1.102e-017 1 421 1.15e+003
2 8 -17.9441 -0.3667 1 73.1 199
3 11 -33.6105 -0.2489 1 -7.44 63.2
4 14 -35.1281 -0.1943 1 0.484 8.86
5 17 -35.1563 -0.201 1 0.00289 0.43
6 20 -35.1564 -0.2007 1 -9.43e-007 0.00303
Optimization terminated: Magnitude of directional derivative in search
direction less than 2*options.TolFun and maximum constraint violation
is less than options.TolCon.
No active inequalities
--------------------------------------------------------------------------------------
个人感觉应该是:options = optimset('Display','iter','TolCon',10^-12,'TolFun',10^-4,'TolX',10^-6);
和[ kappa3 LL3] = fmincon('claytonCL',theta0,[],[],[],[],lower,[],[],options,1-[u,v]);
出错了。
由于刚开始学习MATLAB,所以还不能很好的定位错误,不知哪位前辈能给我些指点。
在下不慎感谢。