Keyword: AGARCH, 非対称, 実現値
概要
本サンプルはAGARCH(非対称GARCH) type1プロセスの実現値の生成を行うC#によるサンプルプログラムです。 本サンプルは以下の式で示されるAGARCH type1モデルにより10個の観測値から成る2つの実現値を生成し出力します。
※本サンプルはnAG Library for .NETに含まれる関数 g05pd() のExampleコードです。本サンプル及び関数の詳細情報は g05pd のマニュアルページをご参照ください。
ご相談やお問い合わせはこちらまで
出力結果
(本関数の詳細はg05pd のマニュアルページを参照)| この出力例をダウンロード |
g05pd Example Program Results
Realisation Number 1
I HT(I) ET(I)
--------------------------------------
1 0.9440 0.3389
2 0.8502 -1.1484
3 2.2553 0.9943
4 1.4918 1.0204
5 1.3413 -1.4544
6 2.9757 -0.0326
7 1.6386 -0.3767
8 1.5433 0.9892
9 1.1477 -0.0049
10 1.0281 0.4508
Realisation Number 2
I HT(I) ET(I)
--------------------------------------
1 0.8691 -1.5286
2 3.0485 -1.1339
3 2.9558 0.5424
4 1.6547 -2.0734
5 4.7100 0.5153
6 2.0336 -0.8373
7 2.3331 -1.0912
8 2.4417 3.8999
9 8.7473 3.8171
10 10.4783 0.2480
- 7〜16行目に1つめの実現値の条件付き分散と観測値が出力されています。
- 21〜30行目に2つめの実現値の条件付き分散と観測値が出力されています。
ソースコード
(本関数の詳細はg05pd のマニュアルページを参照)
※本サンプルソースコードは .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 G05PDE
{
const int mseed=1;
static void Main(String[] args)
{
StartExample();
}
public static void StartExample()
{
try
{
const int num=10;
const int ip=0;
const int iq=3;
double gamma=0.0;
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*(ip+iq+2)];
double[] theta = new double[ip+iq+1];
int[] seed = new int[mseed];
int ifail;
Console.WriteLine("g05pd 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";
gamma = -0.40e0;
theta[0] = 0.80e0;
theta[1] = 0.60e0;
theta[2] = 0.20e0;
theta[3] = 0.10e0;
df = 0;
fcall = true ;
// Generate the first realisation
G05.g05pd(dist, num, ip, iq, theta, gamma, df, ht, et, fcall, r, g05State, out ifail);
if (ifail != 0)
{
Console.WriteLine("** g05pd 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.g05pd(dist, num, ip, iq, theta, gamma, df, ht, et, fcall, r, g05State, out ifail);
if (ifail != 0)
{
Console.WriteLine("** g05pd 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");
}
}
}
}
