Dear Ox-users,
Being relative new in Ox, I tried to make a program
in order to estimate a Garch(1,1), without using the
G@rch package, because I think that writing your own
code is the best way to learn. However, I did not
manage to make it work.
So, I have two small requests.
1)Does anyone have a code for Garch(1,1)
2)I am sending you my version of code, in order to
help understand where I am doing the mistake.
Thank you in advance.
Yours,
Timothy
#include <oxstd.h>
#include <oxfloat.h>
#import <maximize>
static decl res,x,res1;
fLoglik (const vP, const adFunc, const avScore, const
amHess)
{
decl dsum, res, res1, h0,h;
x = loadmat("c:/test.xls"); //Load a matrix
(2000,1)
dsum = sumsqrc(x-vP[0])/rows(x);
res = x-vP[0]; //Create the residuals
res1 = lag0(res,1); //Create the lag residuals
h0=meanc(res.^2); //To start up the Variace Process
h = vP[1]+vP[2]*(res1.^2)+vP[3]*h0; // The Variance
adFunc[0]= double ( -0.5 * (log(M_2PI*h)+dsum/h));
return 1;
}
main()
{
decl vtheta, dfunc;
vtheta = <0.0002;0.001;0.2;0.6>;
fLoglik(vtheta, &dfunc, 0, 0);
print("function value is ", 2000*dfunc, "at parameter
value: ", vtheta');
MaxControl (-1,5);
MaxBFGS(fLoglik, &vtheta, &dfunc, 0, TRUE);
print("function value is ", 2000*dfunc, "at parameter
value: ", vtheta');
}
____________________________________________________________
Do You Yahoo!?
Αποκτήστε τη δωρεάν @yahoo.gr διεύθυνση σας στο http://www.otenet.gr
|