Page 1 of 1

Changing Distribution in MAXIMIZE function

Posted: Wed Oct 05, 2011 12:57 pm
by yukun
Dear Tom,

I am trying to use Maximize function to estimate some sepecial forms of GARCH models. I would like to change the distribution from Normal to t distribution or GED, do you know how to change distrubtions in Maximize function? Thank you very much in advance!

Best Regards,

Yukun

Re: Changing Distribution in MAXIMIZE function

Posted: Wed Oct 05, 2011 4:08 pm
by TomDoan
Use %logtdensity or %loggeddensity rather than %logdensity in the likelihood formula. Both of those have a "shape" parameter. The best idea for estimating that is to initialize that to a value that fattens the tails a bit (10-20 for the t, 2 for the GED).

Re: Changing Distribution in MAXIMIZE function

Posted: Thu Oct 06, 2011 6:30 am
by yukun
Here is my code. Could you please show me how to add % loggeddensity in this code?

Code: Select all

OPEN DATA "V:\Chapter2\futures.xls"
DATA(FORMAT=XLS,ORG=COLUMNS) 1 1687 futures Rf

set Y = Rf 

COMPUTE GSTART=4, GEND=1687
DECLARE SERIES U   ;* Residuals
DECLARE SERIES H   ;* Variances

set U = 0.0 ; 
set H = 1.0  ;


nonlin VC VA VB VD B1 B2 B3 B4     

FRML HF = exp(VC + VA*log(H{1}) + VB*U{1}/sqrt(H{1}) + VD*abs(U{1})/sqrt(H{1}))
FRML RESID = Y - B1 - B2*Y{1}- B3*H - B4*H*Y{1}
FRML LOGL = (H(T)=HF(T)),(U(T)=RESID(T)),-0.5*(LOG(H(T))+U(T)*U(T)/H(T))
LINREG Y 4 1687
# Y{1} H 

COMPUTE B1=%BETA(1)
COMPUTE B2=%BETA(2)
Compute B3=0
compute B4=0
compute VC=log(%SEESQ),VA=0.012,VB=0.0801,VD=0.0
nlpar (subiter=500)
maximize(method=simplex, recursive, iterations=50,noprint) LOGL GSTART GEND
maximize(method=BFGS,robust,recursive,iter=500,cvcirt=0.00000000001) LOGL GSTART GEND
Best Regards,

Yukun

Re: Changing Distribution in MAXIMIZE function

Posted: Thu Oct 06, 2011 8:15 am
by TomDoan
That's really old GARCH code. A more modern way to write:

FRML LOGL = (H(T)=HF(T)),(U(T)=RESID(T)),-0.5*(LOG(H(T))+U(T)*U(T)/H(T))

is

frml logl = h=hf(t),u=resid(t),%logdensity(h,u)

It's the %logdensity that you need to change to %loggeddensity(u,shape,h)

where you want to add SHAPE to your parameter set.

Re: Changing Distribution in MAXIMIZE function

Posted: Thu Oct 06, 2011 10:23 am
by yukun
Many thanks Tom, I will try this code.

Re: Changing Distribution in MAXIMIZE function

Posted: Thu Dec 15, 2011 3:48 am
by Alepruz
Let's say I would like to evaluate some a bit exotic likelihood functions. Like in this paper:

Volatility Feedback and Risk Premium in GARCH Models with Generalized Hyperbolic Distributions (2011)
at: http://www.bepress.com/snde/vol15/iss3/art6/

Actually I would like to replicate that paper using RATS. (Any insights would be greatly appreciated)

The author provides some code in R, but deals with the likelihood functions by calling them in R from a .dll in fortran.

Would a procedure like that make sense in RATS? such as calling a procedure from a lower level language? Is it possible for an end user?

Re: Changing Distribution in MAXIMIZE function

Posted: Mon Dec 19, 2011 5:05 pm
by TomDoan
The integrating constant on that requires a Bessel function of the 3rd kind, which we haven't yet done in RATS. (We have Bessel functions of the 1st kind).