I'm trying to program a volatility updating rule using iteration. I start with the well know Heston-Nandi model where the returns dynamics are :

enter image description here

with enter image description here is iid standard normal randome variable, where enter image description here is time-varying squared volatility, enter image description here, enter image description here and enter image description here.

I want to do is to write the code associate to the volatility updating rule, explain in this algorithm :

  1. Define enter image description here equals the given unconditional variance which is constant,
  2. Iteration for enter image description here :

enter image description here

to obtain the returns based proxy for spot variances enter image description here. Which yields an updating function that exclusively involves observation :

enter image description here

My program (r-code) is the following:


    # For the example I simulate a GARCH
    #process parameters
    eta = 0.2 #eta = 0 is equivalent to Geometric Brownian Motion
    mu = 100 #the mean of the process

    #GARCH volatility model
    specs = garchSpec(model = list(omega = 0.000001, alpha = 0.5, beta = 0.4)) 
    sigma = garchSim(spec = specs, n = T)

    P_0 = mu #starting price, known
    P = rep(P_0,T)

    for(i in 2:T){
      P[i] = P[i-1] + eta * (mu - P[i-1]) + sigma[i] * P[i-1]

    # Set the parameters :
para<-c(0.1,0.2,0.3,0.4,0.5,0.7) # (beta_0,beta_1, beta_2, beta_3, r, gamma) 
    # Iteration to obtain the volatility associate to the model :

vol = c()
for (i in 2:length(P)){
      para_vol <- para[1:6]
      vol[i]=para_vol[1]+ (para_vol[2]*vol[i-1])+ (para_vol[3]/vol[i-1])*(P[i-1]-para_vol[5]-(para_vol[4]+para_vol[6])*vol[i-1])

This is an example where I simulate a GARCH (as data set), the I am trying to extract the volatility associate to the Heston-Nandi model.

I known, I´m using a lot of bad things for r, but I could not figure out a better solution. So my question is it correct?

Any correction and suggestion to improve this process! please feel free to share your extant code in R.

Huge thanks!

  • 1
    $\begingroup$ As this seems to be a mostly conceptual question, my advice is that you'll get more traction for it on stats.stackexchange.com. $\endgroup$
    – Robert Dodier
    Jan 16, 2015 at 1:09

1 Answer 1


There are two answers to your question

  1. If you want to use the Neston-Nandi model, you can use it directly with the parameters that you already show above:

model = list(omega = 0.000001, alpha = 0.5, beta = 0.4)

In r, the fOptions package has an HN model that can use them:

HNGOption(TypeFlag, model, S, X, Time.inDays, r.daily)

  1. If you want to calculate your own option price using garch params, you need to simulate the spot (or stock) price process as well as the volatility process. Your first set of equations show how the Return (the change in the spot price) is updated for each period.

The best book or reference I have seen that explains the implementation of the HN model is 'Option Pricing Models and Volatility' by Rouah and Vainberg. The code is VBA, but the explanation is very good..


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.