Keyword: EGARCH, 実現値
概要
本サンプルはEGARCHプロセスの時系列の実現値の生成を行うC#によるサンプルプログラムです。 本サンプルは以下の式で示されるEGARCHモデルにより10個の観測値から成る2つの実現値を生成し出力します。
※本サンプルはnAG Library for .NETに含まれる関数 g05pg() のExampleコードです。本サンプル及び関数の詳細情報は g05pg のマニュアルページをご参照ください。
ご相談やお問い合わせはこちらまで
出力結果
(本関数の詳細はg05pg のマニュアルページを参照)| この出力例をダウンロード |
g05pg Example Program Results
Realisation Number 1
I HT(I) ET(I)
--------------------------------------
1 2.5098 0.5526
2 2.1785 -1.8383
3 3.3844 1.2180
4 2.6780 1.3672
5 2.0953 -1.8178
6 3.2813 -0.0343
7 2.9958 -0.5094
8 3.0815 1.3978
9 2.3961 -0.0070
10 2.2445 0.6661
Realisation Number 2
I HT(I) ET(I)
--------------------------------------
1 1.9327 -2.2795
2 3.5577 -1.2249
3 4.1461 0.6424
4 3.4455 -2.9920
5 5.9199 0.5777
6 4.8221 -1.2894
7 5.3174 -1.6473
8 6.1095 6.1689
9 3.1579 2.2935
10 2.2189 0.1141
- 7〜16行目に1つめの実現値の条件付き分散と観測値が出力されています。
- 21〜30行目に2つめの実現値の条件付き分散と観測値が出力されています。
ソースコード
(本関数の詳細はg05pg のマニュアルページを参照)
※本サンプルソースコードは .NET環境用の科学技術・統計計算ライブラリである「nAG Library for .NET」の関数を呼び出します。
サンプルのコンパイル及び実行方法
| このソースコードをダウンロード |
// g05pg Example Program Text
// C# version, nAG Copyright 2008
using System;
using NagLibrary;
using System.IO;
namespace NagDotNetExamples
{
public class G05PGE
{
static void Main(String[] args)
{
StartExample();
}
public static void StartExample()
{
try
{
const int mseed=1;
const int num=10;
const int ip=1;
const int iq=1;
int df, genid, i, subid;
bool fcall=false;
string dist="";
double[] et = new double[num];
double[] ht = new double[num];
double[] r = new double[2*(2*iq+ip+2)];
double[] theta = new double[2*iq+ip+1];
int[] seed = new int[mseed];
int ifail;
Console.WriteLine("g05pg Example Program Results");
Console.WriteLine("");
// Initialise the seed
seed[0] = 1762543;
// genid and subid identify the base generator
genid = 1;
subid = 1;
// Initialise the generator to a repeatable sequence
G05.G05State g05State = new G05.G05State(genid, subid, seed, out ifail);
if (ifail != 0)
{
Console.WriteLine("** Generator initialisation failed with ifail = {0,5}", ifail);
goto L60;
}
// Set up the parameters for the series being generated
dist = "N";
theta[0] = 0.10e0;
theta[1] = -0.30e0;
theta[2] = 0.10e0;
theta[3] = 0.90e0;
df = 0;
fcall = true ;
// Generate the first realisation
G05.g05pg(dist, num, ip, iq, theta, df, ht, et, fcall, r, g05State, out ifail);
if (ifail != 0)
{
Console.WriteLine("** g05pg failed with ifail = {0,5}", ifail);
goto L60;
}
// Display the results
Console.WriteLine("");
Console.WriteLine(" {0}"," Realisation Number 1");
Console.WriteLine(" {0}"," I HT(I) ET(I)");
Console.WriteLine(" {0}"," --------------------------------------");
for (i = 1 ; i <= num ; i++)
{
Console.WriteLine(" {0,5} {1,16:f4} {2,16:f4}",i,ht[i - 1],et[i - 1]);
}
// Generate a second realisation
fcall = false ;
G05.g05pg(dist, num, ip, iq, theta, df, ht, et, fcall, r, g05State, out ifail);
if (ifail != 0)
{
Console.WriteLine("** g05pg failed with ifail = {0,5}", ifail);
goto L60;
}
// Display the results
Console.WriteLine("");
Console.WriteLine(" {0}"," Realisation Number 2");
Console.WriteLine(" {0}"," I HT(I) ET(I)");
Console.WriteLine(" {0}"," --------------------------------------");
for (i = 1 ; i <= num ; i++)
{
Console.WriteLine(" {0,5} {1,16:f4} {2,16:f4}",i,ht[i - 1],et[i - 1]);
}
//
L60: ;
//
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine( "Exception Raised");
}
}
}
}
