I've got a question as to minimising the sum of squared errors across "i" and "j" both, hence concerns with two summation operators, by MATLAB. I know that lsqnonlin performs single-summation minimisation problem as in the code I've posted below, but does the same thing apply to double-summation minimisation problem or should I better use fminsearch?
This code I posted does daily calibration across options on the same day, but what I want to do is aggregate calibration both across options on the same day and over a period of days, as is done in Bakshi, Cao, and Chen (1997): http://www.rhsmith.umd.edu/faculty/gbakshi/jf97b.pdf (in the author's homepage)
What is advantage of using lsqnonlin over fminsearch? I have heard and read lots about them on the web, but can't get it well.
P.S. the code is easily found on the web, and the title of the paper that contains it in the appendix is "The Heston Model - A Practical Approach with Matlab Code" by Moodley (2005).
NoOfIterations = 0;
load OptionData.m ;
%OptionData = [r,T,S0,K,Option Value,bid,offer]
Size = size(OptionData);
NoOfOptions = Size(1);
%input sequence in initial vectors [2*kappa*theta - sigma^2,...
x0 = [6.5482 0.0731 2.3012 -0.4176 0.1838];
lb = [0 0 0 -1 0];
ub = [20 1 5 0 1];
options = optimset('MaxFunEvals',20000);
%sets the max no. of iteration to 20000 so that termination
%doesn't take place early.
Calibration = lsqnonlin(@HestonDifferences,x0,lb,ub);
Solution = [(Calibration(1)+Calibration(3)^2)/ ...
function ret = HestonDifferences(input)
NoOfIterations = NoOfIterations + 1;
%counts the no of iterations run to calibrate model
for i = 1:NoOfOptions
PriceDifference(i) = (OptionData(i,5)-HestonCallQuad( ...
%input matrix = [kappa theta sigma rho v0]
ret = PriceDifference';