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 [1].

The DAX implied volatility surface based on July 5, 2002 data taken from [2] 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.).

The diagram above shows the “goodness of fit”-surface for the parameter sets in

To be able to compare a larger number of deterministic optimizers the model calibration will be carried out using R and with help of the additional packages minpack.lm and minqa.

**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 best methods are the non-linear least square algorithms nls.lm and nls followed by nl2sol. Algorithms not included in the diagram have performed even worse than “nm” for this problem.

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.

1] A. Elices, Models with time-dependent parameters using transform methods: application to Heston’s model,