I have a question about the optimizer method to calibrate the parameters of two factor hull white model. I have the analytical pricing formula for cap and market cap price. There are five parameters need to calibrate ($\gamma_1$. $\gamma_2$, $\sigma_1$, $\sigma_2$, $\rho$). The problem is I can not get the fixed parameters, when I change the initial guess for these five paras, I will get different result. Any suggestions are appreciated.

The optimize code is as following:

minimize(error_func, initial_guess, args = (strikes, cap_tenor, zcb, cap_price_market), 
                                            bounds=bound, method="Nelder-Mead")

2 Answers 2


You are obviously using a local-optimizer ( here Nelder-Mead method). One should expect different results for different initial guesses as it will get stuck to a local minima ( or just a "solution" for Nelder-Mead, as it is a heuristic optimizer). In practice, play around and collect the different solutions and their errors, the smaller the error , the better. You can also use the differential evolution optimizer which is a global optimizer, it is slower but it can give you a good indication of where the actual solution is.

The calibrating instruments is also another thing that you should look at. If you remove one instrument, you might get totally different results. You can compromise the accuracy( i.e. choosing the set of parameters that yields the smallest error) for stability

  • $\begingroup$ Thank you for your reply. I have some further questions want to ask. How will you choose the target function? I use the $\sum(c_{model} - c_{market})^2$, which give me very small error, even I am in local minima. And does HW2 model use a lot in practice? Since it look so hard to calibrate the parameters (for me). $\endgroup$
    – wen
    Feb 11, 2020 at 21:50

I have been working with the HW2 model for three years (medium-sized European Bank). I calibrate the paramters on ATM-swaption volatilities. As @Canardini said in his answer, it might be better to do also include a global search for optimal paramters.

I use the following procedure:

Day1: First use a global search algorithm (I use controlled random search, which is implemented in nlopt). Then use a local-optimizer and use the result of the global search as a starting point.

Then on Day2: Use only a local-optimizer and use the optimal values from Day1 as starting values. If the value of the target function for both days is similar, then we are finished. Otherwise do a global search followed by local-optimization.

As a target function I use $$ \sum ( c_{i, \text{model}} - c_{i, \text{market}})^2 \cdot \text{vega}_i, $$

where $\text{vega}_i$ is the (analytical) vega of swaption $i$.

Here is some R-code skeleleton:

global <- nloptr::nloptr(
  x = as.numeric(local_start)[1:5], eval_f = target_fun,
  lb = c(1e-7, 1e-7,  1e-7, 1e-7, -1 + 1e-7),
  ub = c(2, 2, 0.1, 0.1, 1 - 1e-7),
  opts = list(algorithm = "NLOPT_GN_CRS2_LM", ftol_abs = 5e-6,
              xtol_rel = 5e-6, ranseed = 1234, maxeval = 1e4)

local <- nloptr::nloptr(
  x = global$solution, eval_f = target_fun,
  lb = c(1e-7, 1e-7,  1e-7, 1e-7, -1 + 1e-7),
  ub = c(2, 2, 0.1, 0.1, 1 - 1.e-7),
  opts = list(algorithm = "NLOPT_LN_NELDERMEAD", ftol_abs = 1e-8,
              xtol_rel = 1e-8, ranseed = 1234, maxeval = 1e4)
  • $\begingroup$ I want to know why vega is multiplied in the target function. Does it work as a weight? $\endgroup$ Apr 7 at 7:12
  • $\begingroup$ yes exactly, we give high-vega swaptions a higher weight during the optimization. I did some experiments and this yielded the most robust results. $\endgroup$
    – Cettt
    Apr 8 at 13:48
  • $\begingroup$ Then I wonder if there is any reference that deals with the vega as a weight. Because I want to justify that theoretically. Is it just your empirical method with your experiments? $\endgroup$ Apr 13 at 2:53
  • $\begingroup$ Almost textbooks, that I have written, suggest $∑(c_{i,model}−c_{i,market})^2$ as target function. $\endgroup$ Apr 13 at 2:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.