28 using namespace RBD_LIBRARIES;
49 : Y(y), X(x), n(y.nrows()) {}
55 beta = para(1); alpha0 = para(2);
56 alpha1 = para(3); beta1 = para(4);
66 {
return alpha0>0 && alpha1>0 && beta1>0 && (alpha1+beta1)<1.0; }
91 Real denom = (1-alpha1-beta1);
94 Hderiv(1,2) = 1.0 / denom;
95 Hderiv(1,3) = alpha0 /
square(denom);
96 Hderiv(1,4) = Hderiv(1,3);
100 for (
int i=2; i<=n; i++)
103 Real h = alpha0 + alpha1*
square(u1) + beta1*h1;
104 H(i) = h;
Real u = U(i);
105 LL += log(h) +
square(u) / h;
108 Hderiv(i,1) = -2*u1*alpha1*X(i-1) + beta1*Hderiv(i-1,1);
109 Hderiv(i,2) = 1 + beta1*Hderiv(i-1,2);
110 Hderiv(i,3) =
square(u1) + beta1*Hderiv(i-1,3);
111 Hderiv(i,4) = h1 + beta1*Hderiv(i-1,4);
112 LH(i) = -0.5 * (1/h -
square(u/h));
125 D2 << Hderiv.
t() * Hderiv; D2 = D2 / 2.0;
140 if (!wg) cout << endl <<
"unexpected call of FI" << endl;
148 ifstream fin(
"garch.dat");
149 if (!fin) { cout <<
"cannot find garch.dat\n"; exit(1); }
154 for (i=1; i<=n; i++) fin >> Y(i) >> X(i);
155 cout <<
"Read " << n <<
" data points - begin fit\n\n";
159 MLE_D_FI mle_d_fi(garch11,100,0.0001);
161 Para << 0.0 << 0.1 << 0.1 << 0.1;
167 cout <<
"estimates and standard errors\n";
168 cout << setw(15) << setprecision(5) << (Para | SE) << endl << endl;
171 cout <<
"correlation matrix\n";
172 cout << setw(10) << setprecision(2) << Corr << endl << endl;
173 cout <<
"inverse of correlation matrix\n";
174 cout << setw(10) << setprecision(2) << Corr.i() << endl << endl;
192 cout <<
"\nProgram fails - exception generated\n\n";
void GetCorrelations(SymmetricMatrix &)
void Set(const ColumnVector &p)
GARCH11_LL(const ColumnVector &y, const ColumnVector &x)
TransposedMatrix t() const
DiagedMatrix as_diagonal() const
void Fit(ColumnVector &Parameters)
The usual rectangular matrix.
static const char * what()
void GetStandardErrors(ColumnVector &)
GetSubMatrix row(int) const
ReturnMatrix Derivatives()