The gaol is to calibrate a time dependent Heston model defined by the following SDE
The parameter set is supposed to be piecewise constant in time. This model has a semi-closed solution for plain vanilla European put/call options based on the characteristic function method .
The DAX implied volatility surface based on July 5, 2002 data taken from  defines the “benchmark” calibration problem. The benchmark model parameters for the optimization problem are given by
The non-linear least square optimization problem is defined by the goodness of fit measure
where is the market implied volatility for strike K and maturity T and is the corresponding Black-Scholes volatility implied from the model price. The optimal solution for this problem is
leading to a goodness of fit measure of (Please keep in mind that this result is the outcome of a naive calibration procedure. Due to the large and values I’d not use these parameters to price a derivative.).
Non-linear Least Square Optimization:
- nls.lm: Levenberg-Marquardt algorithm(based on MINPACK, also available in QuantLib)
- nls: Gauss-Newton algorithm
- nl2sol:based on the PORT library.
Non-linear (trusted region) Minimization:
- nlm:Newton style minizer
- bfgs: quasi-Newton method published by Broyden, Fletcher, Goldfarb and Shanno
- l-bfgs-b: limited memory BFGS algorithm incl.box constraints
- cg: conjugate gradient algorithm
- nm: Nelder-Mead method
- bobyqa:trust region method that forms quadratic models by interpolation.
- newuoa: trust region method that forms quadratic models by interpolation.
- uobyqa:trust region method that forms quadratic models by interpolation.
The particular result dependents on the starting vector but the following diagram shows a common outcome.
The goodness of fit measure is calculated in C++ based on the QuantLib and exposed to R using RCPP. The C++ code and the R scripts to perform the optimizations and to create the plots can be found here.