Appendix C: Some RATS Programs for Duration Models

The data used are adjusted time durations of intraday transactions of IBM stock from November 1 to November 9, 1990. The file name is ibm1to5.txt and it has 3534 observations.

Program for Estimating a WACD(1,1) Model

all 0  3534:1

open data ibm1to5.txt

data(org=obs) / x r1

set psi = 1.0

nonlin a0 a1 b1 al

frml gvar = a0+a1*x(t-1)+b1*psi(t-1)

frml gma = %LNGAMMA(1.0+1.0/al)

frml gln =al*gma(t)+log(al)-log(x(t)) $

  +al*log(x(t)/(psi(t)=gvar(t)))-(exp(gma(t))*x(t)/psi(t))**al

smpl 2 3534

compute a0 = 0.2, a1 = 0.1, b1 = 0.1, al = 0.8

maximize(method=bhhh,recursive,iterations=150) gln

set fv = gvar(t)                      

set resid = x(t)/fv(t)

set residsq = resid(t)*resid(t)

cor(qstats,number=20,span=10) resid

cor(qstats,number=20,span=10) residsq

Program for Estimating a GACD(1,1) Model

all 0  3534:1

open data ibm1to5.txt

data(org=obs) / x r1

set psi = 1.0

nonlin a0 a1 b1 al ka

frml cv = a0+a1*x(t-1)+b1*psi(t-1)

frml gma = %LNGAMMA(ka)

frml lam = exp(gma(t))/exp(%LNGAMMA(ka+(1.0/al)))

frml xlam = x(t)/(lam(t)*(psi(t)=cv(t)))

frml gln =-gma(t)+log(al/x(t))+ka*al*log(xlam(t))

   -(xlam(t))**al

smpl 2 3534

compute a0 = 0.238, a1 = 0.075, b1 = 0.857, al = 0.5, ka = 4.0

nlpar(criterion=value,cvcrit=0.00001)

maximize(method=bhhh,recursive,iterations=150) gln

set fv = cv(t)                      

set resid = x(t)/fv(t)

set residsq = resid(t)*resid(t)

cor(qstats,number=20,span=10) resid

cor(qstats,number=20,span=10) residsq

Program ...

Get Analysis of Financial Time Series, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.