Question about "optimset" option LineSearchType

2 visualizaciones (últimos 30 días)
Dilyana
Dilyana el 18 de Jun. de 2014
Editada: Matt J el 18 de Jun. de 2014
I have an old piece of code that uses optimset with the following options:
"options = optimset('LargeScale', 'off', 'HessUpdate', 'dfp', 'LineSearchType', 'quadcubic','MaxFunEvals', MaxFunEvals, ... 'display', 'off', 'MaxIter', MaxIter, 'TolFun', 1e-8, 'TolX', 1e-8);"
I get the following error" "Error using optimset (line 211) The LineSearchType option is no longer valid. It was only used by the Gauss-Newton algorithm, which is no longer used in Optimization toolbox solvers."
Dropping the option does not work. What would be a suitable replacement?
Thanks!
  2 comentarios
Star Strider
Star Strider el 18 de Jun. de 2014
  1. We need to know more about your code, what it’s doing (or intends to do), what solver it uses, and for what purpose.
  2. What does ‘does not work’ mean?
  3. Posting the relevant section of code would help.
Dilyana
Dilyana el 18 de Jun. de 2014
Editada: Matt J el 18 de Jun. de 2014
Dropping the option, the code works but I cannot obtain convergence. Since the code is not mine but an old code of a published paper that computes CAViAR, it should work.
Here is the code reproduced:
function [quantile, dq] = CAViaROptimisation(y, THETA, C)
% ****************************************************************************************************************************************
% * *
% * Codes for the paper "Measuring Comovements by Regression Quantiles" by Lorenzo Cappiello, *
% * Bruno Gerard and Simone Manganelli *
% * *
% * By SIMONE MANGANELLI, European Central Bank, Frankfurt am Main. *
% * Created on 26 May, 2004. Last modified 13 April 2005. *
% * *
% ****************************************************************************************************************************************
%
%
%************ INPUTS *********************
%
% y = (T,1) time series of returns
% THETA = confidence level of the Value at Risk
% C = Crisis dummy
%
%************ OUTPUT *********************
%
% quantile = (T,1)-vector of estimated quantiles
% dq = vector of quantile derivatives
%
%*****************************************************************************************
% *****************************************************************************************
% Set parameters for optimisation.
% *****************************************************************************************
T = length(y);
%REP = 5; % Number of times the optimization algorithm is repeated.
%nInitialVectors = [1000, 3]; % Number of initial vector fed in the uniform random number generator for AS model.
%nInitialVectors = [1, 5]; % Number of initial vector fed in the uniform random number generator for AS model.
nInitialCond = 5; % Select the number of initial conditions for the optimisation.
MaxFunEvals = 100; % Parameters for the optimisation algorithm. Increase them in case the algorithm does not converge.
MaxIter = 100;
options = optimset('LargeScale', 'off', 'HessUpdate', 'dfp', 'LineSearchType', 'quadcubic' ,'MaxFunEvals', MaxFunEvals, ...
'display', 'off', 'MaxIter', MaxIter, 'TolFun', 1e-8, 'TolX', 1e-8);
warning off
% Compute the empirical THETA-quantile for y (the in-sample vector of observations).
%empiricalQuantile = ysort(round(300*THETA));
empiricalQuantile = prctile(y(1:300), THETA*100);
eps = 1e-10;
%
%
%**************************** Optimization Routine ******************************************
initialTargetVectors = [unifrnd(-.1, .1, nInitialCond, 3), unifrnd(.7, .99, nInitialCond, 1), unifrnd(-.1, .1, nInitialCond, 1)];
b=[];
for i = 1:nInitialCond
b0 = initialTargetVectors(i,:)'; b0 = b0; b1 = b0+3*eps;
RQ1 = 1e10;
while norm(b1-b0)>eps
b0 = b1; %RQ0 = RQ1;
b1 = fminsearch('CAViaR', b0, [], y, C, THETA, 1);
end
q = CAViaR(b1, y, C, THETA, 0);%q = CAViaR(y, b0, C, .05);
RQ1 = abs(THETA-(y<q))'*abs(y-q);
b = [b;RQ1/100, b1'];
end
b
[aa,a] = min(b(:,1));
b1 = b(a,2:end)';
%************************** Compute variables that enter output *****************************
% Compute VaR and Hit for the estimated parameters of RQ.
quantile = CAViaR(b1, y, C, THETA, 0);
%return
% Compute gradient
dq1 = zeros(T,1); dq2 = dq1; dq3 = dq1; dq4 = dq1; dq5 = dq1; q = dq1;
for i = 3:T
q(i) = b1(1) + b1(2)*C(i) + b1(3)*y(i-1) + b1(4)*q(i-1) - b1(3)*b1(4)*y(i-2) + b1(5)*abs(y(i-1));
dq1(i,1) = 1 + b1(4) * dq1(i-1,1);
dq2(i,1) = C(i) + b1(4) * dq2(i-1,1);
dq3(i,1) = y(i-1) + b1(4) * dq3(i-1,1) - b1(4)*y(i-2);
dq4(i,1) = q(i-1) + b1(4)*dq4(i-1,1) - b1(3)*y(i-2);
dq5(i,1) = abs(y(i-1)) + b1(4) * dq5(i-1,1);
end
dq = [dq1, dq2, dq3, dq4, dq5];

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 18 de Jun. de 2014
Editada: Matt J el 18 de Jun. de 2014
The "options" variable created with optimset is never used in the code. It is having no effect. It looks like the author changed his mind and switched from another another optimization tool to fminsearch. You could try instead
optimset('TolFun', 1e-8, 'TolX', 1e-8,'MaxFunEvals', MaxFunEvals, ...
'display', 'off', 'MaxIter', MaxIter,);
b1 = fminsearch('CAViaR', b0, options, y, C, THETA, 1);
You will have to experiment to find appropriate values for the above options, however. MaxIter=MaxFunEvals=100 is probably too small for a 5-variable problem.

Categorías

Más información sobre Optimization en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by