<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="gfn2html.xsl"?>
<gretl-functions>
<gretl-function-package name="nic_gig" needs-time-series-data="true" minver="2024a">
<author email="tpanag@uom.edu.gr">Mary Mertzanidou and Theodore Panagiotidis</author>
<version>1.0</version>
<date>2026-09-16</date>
<description>News Impact Curves for GARCH and GJR-GARCH</description>
<tags>ts finance volatility</tags>
<help>
This package draws the News Impact Curves (NIC) for a GARCH(1,1)
and a GJR-GARCH(1,1) model on the same graph.

Implements the analytical NIC formulas from:
Engle, R.F. and Ng, V.K. (1993). Measuring and testing the impact
of news on volatility. Journal of Finance, 48(5), 1749-1778.

Both models must first be estimated with the gig package (this
package requires gig to be installed), with AR lags = 1.

This package provides one public function:

nic_plot_from_gig(mod_garch, mod_gjr)
Takes two gig bundles (a GARCH(1,1), type 1, and a GJR-GARCH(1,1),
type 3) and plots both News Impact Curves on the same graph.

Parameters:

mod_garch : gig bundle holding a fitted GARCH(1,1) model
            (gig type = 1, estimated with AR lags = 1).

mod_gjr   : gig bundle holding a fitted GJR-GARCH(1,1) model
            (gig type = 3, estimated with AR lags = 1).

NIC formulas (Engle and Ng, 1993):
  GARCH:     h(e) = A + alpha * e^2
  GJR (e &gt;= 0): h(e) = A + alpha * e^2
  GJR (e &lt; 0):  h(e) = A + (alpha + gamma) * e^2
  where A = omega + beta * hbar
  and hbar = omega / (1 - alpha - beta)

Printed output:

Each call also prints the estimated coefficients and derived
NIC quantities for both models to the console:

  omega : constant term in the variance equation
  alpha : coefficient on the squared shock (ARCH term)
  gamma : (GJR only) extra coefficient applied when the shock
          is negative, captures the leverage/asymmetry effect
  beta  : coefficient on lagged conditional variance (GARCH
          term)
  hbar  : the model's implied long-run (unconditional) variance
  A     : the NIC curve's baseline height at e_{t-1} = 0
</help>
<depends count="1">
gig </depends>
<gretl-function name="nic_plot_from_gig" type="void">
 <params count="2">
  <param name="mod_garch" type="bundle" const="true">
<description>GARCH(1,1) bundle from gig (type 1)</description>
  </param>
  <param name="mod_gjr" type="bundle" const="true">
<description>GJR-GARCH(1,1) bundle from gig (type 3)</description>
  </param>
 </params>
<code># --- extract GARCH coefficients ---
matrix cg   = mod_garch.coeff
scalar g_omega = cg[3]
scalar g_alpha = cg[4]
scalar g_beta  = cg[6]
scalar g_hbar  = g_omega / (1 - g_alpha - g_beta)
scalar g_A     = g_omega + g_beta * g_hbar

# --- extract GJR coefficients ---
matrix cgjr    = mod_gjr.coeff
scalar gjr_omega = cgjr[3]
scalar gjr_alpha = cgjr[4]
scalar gjr_gamma = cgjr[5]
scalar gjr_beta  = cgjr[6]
scalar gjr_hbar  = gjr_omega / (1 - gjr_alpha - gjr_beta)
scalar gjr_A     = gjr_omega + gjr_beta * gjr_hbar

# --- print for verification ---
printf &quot;\n--- GARCH(1,1) ---\n&quot;
printf &quot;  omega = %.6e\n&quot;, g_omega
printf &quot;  alpha = %.6e\n&quot;, g_alpha
printf &quot;  beta  = %.6e\n&quot;, g_beta
printf &quot;  hbar  = %.6e\n&quot;, g_hbar
printf &quot;  A     = %.6e\n&quot;, g_A

printf &quot;\n--- GJR-GARCH(1,1) ---\n&quot;
printf &quot;  omega = %.6e\n&quot;, gjr_omega
printf &quot;  alpha = %.6e\n&quot;, gjr_alpha
printf &quot;  gamma = %.6e\n&quot;, gjr_gamma
printf &quot;  beta  = %.6e\n&quot;, gjr_beta
printf &quot;  hbar  = %.6e\n&quot;, gjr_hbar
printf &quot;  A     = %.6e\n\n&quot;, gjr_A

# --- plot ---
string fname = sprintf(&quot;%snic_combined.gp&quot;, $dotdir)

set force_decpoint on

outfile @fname
  printf &quot;set encoding utf8\n&quot;
  printf &quot;set linetype 1 lc rgb '#0072B2' lw 2.5\n&quot;
  printf &quot;set linetype 2 lc rgb '#D55E00' lw 2.5\n&quot;
  printf &quot;set title 'News Impact Curves - GARCH(1,1) vs GJR-GARCH(1,1)'\n&quot;
  printf &quot;set xlabel 'Standardised Residual (e_{t-1})'\n&quot;
  printf &quot;set ylabel 'Conditional Variance h_t'\n&quot;
  printf &quot;set xzeroaxis lt -1 lw 1 lc rgb '#808080'\n&quot;
  printf &quot;set border 15\n&quot;
  printf &quot;set grid\n&quot;
  printf &quot;set key left top\n&quot;
  printf &quot;set xrange [-3:3]\n\n&quot;
  printf &quot;garch_nic(x) = %g + %g*x**2\n&quot;, g_A, g_alpha
  printf &quot;gjr_nic(x) = (x &lt; 0) ? %g + %g*x**2 : %g + %g*x**2\n&quot;, gjr_A, gjr_alpha+gjr_gamma, gjr_A, gjr_alpha
  printf &quot;plot garch_nic(x) title 'GARCH(1,1)' w lines lt 1, \\\n&quot;
  printf &quot;     gjr_nic(x)   title 'GJR-GARCH(1,1)' w lines lt 2\n&quot;
end outfile

gnuplot --input=@fname --output=display
</code>
</gretl-function>
<sample-script>
include nic_gig.gfn
include gig.gfn
open nysewk
setobs 52 1966-01-05 --time-series

StockPrices = close
Stock = interpol(StockPrices)
StockReturns = ldiff(Stock)
smpl +1 ;

bundle mod_g = gig_setup(StockReturns, 1, const, null, 1)
gig_estimate(&amp;mod_g, 0)

bundle mod_gjr = gig_setup(StockReturns, 3, const, null, 1)
gig_estimate(&amp;mod_gjr, 0)

# Plot NICs
nic_plot_from_gig(mod_g, mod_gjr)
</sample-script>
</gretl-function-package>
</gretl-functions>

