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 singlesummation minimisation problem as in the code I've posted below, but does the same thing apply to doublesummation 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.
Thanks, Jason
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).
global OptionData; global NoOfOptions; global NoOfIterations; global PriceDifference;
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,... % theta,sigma,rho,v0] 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.
tic; Calibration = lsqnonlin(@HestonDifferences,x0,lb,ub); toc;
Solution = [(Calibration(1)+Calibration(3)^2)/ ... (2*Calibration(2)), Calibration(2:5)];
function ret = HestonDifferences(input)
global NoOfOptions; global OptionData; global NoOfIterations; global PriceDifference;
NoOfIterations = NoOfIterations + 1; %counts the no of iterations run to calibrate model
for i = 1:NoOfOptions PriceDifference(i) = (OptionData(i,5)HestonCallQuad( ... (input(1)+input(3)^2)/(2*input(2)),input(2), ... input(3),input(4),input(5), ... OptionData(i,1),OptionData(i,2),OptionData(i,3), ... OptionData(i,4)))/sqrt((abs(OptionData(i,6) ... OptionData(i,7))));
%input matrix = [kappa theta sigma rho v0]
end
ret = PriceDifference';
