Keyword: AGARCH, 非対称, 実現値
概要
本サンプルはAGARCH(非対称GARCH) type2プロセスの実現値の生成を行うC#によるサンプルプログラムです。 本サンプルは以下の式で示されるAGARCH type2モデルにより10個の観測値から成る2つの実現値を生成し出力します。
※本サンプルはnAG Library for .NETに含まれる関数 g05pe() のExampleコードです。本サンプル及び関数の詳細情報は g05pe のマニュアルページをご参照ください。
ご相談やお問い合わせはこちらまで
出力結果
(本関数の詳細はg05pe のマニュアルページを参照)| この出力例をダウンロード |
g05pe Example Program Results
Realisation Number 1
I HT(I) ET(I)
--------------------------------------
1 0.6400 0.2790
2 0.5336 -0.9098
3 0.7780 0.5840
4 0.6491 0.6731
5 0.5670 -0.9456
6 0.8275 -0.0172
7 0.6593 -0.2390
8 0.5639 0.5980
9 0.5005 -0.0032
10 0.4303 0.2917
Realisation Number 2
I HT(I) ET(I)
--------------------------------------
1 0.3874 -1.0205
2 0.7594 -0.5659
3 0.7371 0.2709
4 0.6013 -1.2499
5 1.1133 0.2505
6 0.8638 -0.5457
7 0.8014 -0.6395
8 0.8013 2.2341
9 1.0003 1.2908
10 0.9002 0.0727
- 7〜16行目に1つめの実現値の条件付き分散と観測値が出力されています。
- 21〜30行目に2つめの実現値の条件付き分散と観測値が出力されています。
ソースコード
(本関数の詳細はg05pe のマニュアルページを参照)
※本サンプルソースコードは .NET環境用の科学技術・統計計算ライブラリである「nAG Library for .NET」の関数を呼び出します。
サンプルのコンパイル及び実行方法
| このソースコードをダウンロード |
// g05pe Example Program Text
// C# version, nAG Copyright 2008
using System;
using NagLibrary;
using System.IO;
namespace NagDotNetExamples
{
public class G05PEE
{
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;
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*(iq+ip+2)];
double[] theta = new double[ip+iq+1];
int[] seed = new int[mseed];
int ifail;
Console.WriteLine("g05pe 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.080e0;
theta[1] = 0.20e0;
theta[2] = 0.70e0;
gamma = -0.40e0;
df = 0;
fcall = true ;
// Generate the first realisation
G05.g05pe(dist, num, ip, iq, theta, gamma, df, ht, et, fcall, r, g05State, out ifail);
if (ifail != 0)
{
Console.WriteLine("** g05pe 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.g05pe(dist, num, ip, iq, theta, gamma, df, ht, et, fcall, r, g05State, out ifail);
if (ifail != 0)
{
Console.WriteLine("** g05pe 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");
}
}
}
}
