Everything between the FIND and END FIND gets executed with each function evaluation. With your code:
- Code: Select all
find(method=bfgs) minimum Error
com a1=0.1
com sigma1 = .12
com sigma2 = .17
com mu1 = 0.12
com mu2 = 0.15
etc.
you're overwriting your parameter values with your guess values every time, which won't work. Shift those COMPUTEs outside the FIND, and you should be OK, that is:
- Code: Select all
com a1=0.1
com sigma1 = .12
com sigma2 = .17
com mu1 = 0.12
com mu2 = 0.15
find(method=bfgs) minimum Error
etc.
However, isn't there something wrong with:
com Callerr = Callerr + ( Cmay(i)- ( a1*(exp(mu1+0.5*sigma1**2)*%CDF(d1) - 4*%CDF(d2) ) + (1-a1)*( exp(mu2+0.5*sigma1**2)*%CDF(d3) - 4*%CDF(d4) ) ) )**2
There's nothing in your pricing formula (for both puts and calls) that depends upon (i) so that's just going to try to (indirectly) fit the two sample means with five parameters, so the model isn't identified as written.