What is the unconditional variance for a GARCH model?

I want to use a Matlab script to calculate Heston Nandi GARCH prices. I found an appropriate script online and it asks for the "unconditional variance" as an input. How do I calculate the appropriate unconditional volatility? I found this formula online: $$\sigma^2 = s^2 = \frac{1}{n-1} * \sum_{t=1}^n [r^2_t]$$

Is this the appropriate one to use? Do I take the variance according to this formula for all asset returns up to the point in time of the option I am trying to value? Full Script: function OptionPrice=HestonNandi(S_0,X,Sig_,T,r)

%%%%%%%%%%%%% % this function calculates the price of Call option based on the GARCH % option pricing formula of Heston and Nandi(2000). The input to the % function are: current price of the underlying asset, strike price, % unconditional variance of the underlying asset, time to maturity in days, % and daily risk free interest rate. %%%%%%%%%%%

% Author: Ali Boloorforoosh % email: a_bol@jmsb.concordia.ca % Date: Nov. 1,08

            %%%%% sample inputs %%%%%
% S_0=100;                    stock price at time t
% X=100;                      strike prices
% Sig_=.04/252;               unconditional variances per day
% T=30;                       option maturity
% r=.05/365;                  daily risk free rate


% function Integrand1 and Integrand2 return the values inside the
% first and the second integrals

function f1=Integrand1(phi)
f1=real((X.^(-i*phi).*charac_fun(i*phi+1))./(i*phi));
end

function f2=Integrand2(phi)
f2=real((X.^(-i*phi).*charac_fun(i*phi))./(i*phi));
end

% function that returns the value for the characteristic function
function f=charac_fun(phi)

phi=phi';    % the input has to be a row vector

% GARCH parameters
lam=2;
lam_=-.5;                   % risk neutral version of lambda
a=.000005;
b=.85;
g=150;                      % gamma coefficient
g_=g+lam+.5;                % risk neutral version of gamma
w=Sig_*(1-b-a*g^2)-a;       % GARCH intercept

% recursion for calculating A(t,T,Phi)=A_ and B(t,T,Phi)=B_
A(:,T-1)=phi.*r;
B(:,T-1)=lam_.*phi+.5*phi.^2;

for i=2:T-1
A(:,T-i)=A(:,T-i+1)+phi.*r+B(:,T-i+1).*w-.5*log(1-2*a.*B(:,T-i+1));
B(:,T-i)=phi.*(lam_+g_)-.5*g_^2+b.*B(:,T-i+1)+.5.*(phi-g_).^2./(1-2.*a.*B(:,T-i+1));
end

A_=A(:,1)+phi.*r+B(:,1).*w-.5*log(1-2.*a.*B(:,1));                    % A(t;T,phi)
B_=phi.*(lam_+g_)-.5*g_^2+b.*B(:,1)+.5*(phi-g_).^2./(1-2.*a.*B(:,1)); % B(t;T,phi)

f=S_0.^phi.*exp(A_+B_.*Sig_);
f=f'; % the output is a row vector

end


end

• This might help you: quant.stackexchange.com/questions/26357/… – Quantuple Jun 17 '16 at 6:56
• Thanks for the link, it shows the relationship of $\omega$ and unconditional variance, which the script I posted uses to calculate $\omega$ . How can I find the unconditional variance that is required as an input though? Thanks! – SW7 Jun 17 '16 at 11:48
• This might help you: quant.stackexchange.com/questions/26076/… – Quantuple Jun 17 '16 at 11:55
• Thanks for your quick reply. Does this mean that I can simply use the sample variance of, say, the past 20 values of log asset returns as an input and should receive an accurate result? Is this the way the HN-GARCH is usually implemented? Sorry for all the questions, I have looked this up but could not find any info that seemed to serve the script I want to use. – SW7 Jun 17 '16 at 12:33
• So I suppose what I am really asking is how do I implement the specific code above? What do I use for $\sigma$ ? – SW7 Jun 17 '16 at 19:29

I'm not sure if you still need an answer, however, if you take a look at the original paper of Heston&Nandi (2000) you will find that "Sig_" as defined in your code, is similar to their annualized long-run volatility (P.579), except that here it is not annualized.

$\Omega=\frac{\left(\omega+\alpha\right)}{1-\beta-\alpha\gamma^{2}}$

solving this for $\omega$ leads to what your code calls "GARCH intercept".

f=S_0.^phi.*exp(A_+B_.*Sig_)


which is

$CF=S_{t}^{\phi}\exp\left(A\left(t,T,\phi\right)+B\left(t,T,\phi\right)h_{t+1}^{*}\right)$

As you can see, "Sig_" should be the conditional variance of the following time step (in the single-lag case).

Therefore, from what i understand, "Sig_" here is simply an arbitrary starting value for h(0), i.e., the conditional variance.

To answer your question, yes, one could set it equal to the sample variance, but also to any other reasonable value. It barely has any effect on the result and due to the strong mean reversion property of the conditional variance it doesn't matter for longer return samples (few hundred observations).

You should also keep in mind that you have to estimate your own parameters for the data you are using.