Example 1: IBM returns

We will Ruey Tsay’s “Financial Time Series” webpage and upload IBM returns

#install.packages("fBasics")
#install.packages("timeSeries")
#install.packages("TSA")
#library("fBasics")
#library("timeSeries")
#library("TSA")

file = "http://faculty.chicagobooth.edu/ruey.tsay/teaching/fts3/m-ibm3dx2608.txt"
da = read.table(file,header=TRUE)
sibm=da[,2]
sibm2 = sibm^2
par(mfrow=c(1,2))
ts.plot(sibm,main="IBM returns")
ts.plot(sibm2,main="IBM squared returns")

acf(sibm,main="")
acf(sibm2,main="")

Ljung-Box test

Box.test(sibm,lag=30,type="Ljung")
## 
##  Box-Ljung test
## 
## data:  sibm
## X-squared = 38.241, df = 30, p-value = 0.1437
Box.test(sibm2,lag=30,type="Ljung")
## 
##  Box-Ljung test
## 
## data:  sibm2
## X-squared = 182.12, df = 30, p-value < 2.2e-16

Example 2: US real GNP

As an illustration, consider the quarterly growth rate of U.S. real gross national product (GNP), seasonally adjusted, from the second quarter of 1947 to the first quarter of 1991. Here we simply employ an AR(3) model for the data. Denoting the growth rate by \(r_t\) the fitted model is \[ r_t = 0.0047 + 0.348r_{t-1} + 0.179 r_{t-2} -0.142 r_{t-3} + a_t, \] with \({\hat \sigma}_a=0.0097\).

Alternatively, \[ r_t - 0.348r_{t-1} - 0.179 r_{t-2} + 0.142 r_{t-3} = 0.0047 + a_t, \] with the corresponding third-order difference equation \[ (1-0.348B-0.179B^2+0.142B^3)=0 \] or \[ (1+0.521B)(1-0.869B+0.274B^2)=0 \] The first factor \[ (1+0.521B) \] shows an exponentially decaying feature of the GNP.

Business cycles

The second factor \((1-0.869B+0.274B^2)\) confirms the existence of stochastic business cycles.
For an AR(2) model with a pair of complex characteristic roots, the average length of the stochastic cycles is \[ k = \frac{2\pi}{\cos^{-1}[\phi_1/(2\sqrt{-\phi_2})]} \] or \(k=10.62\) quarters, which is about 3 years.

R script and output

dgnp82 = "http://faculty.chicagobooth.edu/ruey.tsay/teaching/fts3/dgnp82.txt"
gnp=scan(file=dgnp82)

# To create a time-series object
gnp1=ts(gnp,frequency=4,start=c(1947,2))

par(mfrow=c(1,1))
plot(gnp1)
points(gnp1,pch="*")