1. The Nature of Time Series Data

Johnson & Johnson Quarterly Earnings

tsplot(jj, type="o", ylab="Quarterly Earnings per Share")

Global Warming

tsplot(globtemp, type="o", ylab="Global Temperature Deviations")

Speech

tsplot(speech)  

Dow Jones Industrial Average

library(quantmod)
getSymbols("^DJI", from="2006-04-20", to="2016-04-20", periodicity="daily")
## [1] "DJI"
djia = DJI
djiar = diff(log(djia$DJI.Close))[-1]         # approximate returns
plot(djiar, main="DJIA Returns", type="l")  

SOI and Fish

par(mfrow = c(2,1))  # set up the graphics
tsplot(soi, ylab="", main="Southern Oscillation Index")
tsplot(rec, ylab="", main="Recruitment") 

fMRI

par(mfrow=c(2,1), mar=c(3,2,1,0)+.5, mgp=c(1.6,.6,0))  
ts.plot(fmri1[,2:5], col=1:4, ylab="BOLD", xlab="", main="Cortex")
ts.plot(fmri1[,6:9], col=1:4, ylab="BOLD", xlab="", main="Thalamus & Cerebellum")
mtext("Time (1 pt = 2 sec)", side=1, line=2) 

Earthquakes and Explosions

par(mfrow=c(2,1))
tsplot(EQ5, main="Earthquake")
tsplot(EXP6, main="Explosion")

2. Time Series Statistical Models

White noise and moving average

w = rnorm(500,0,1)  # 500 N(0,1) variates
v = filter(w, sides=2, rep(1/3,3))  # moving average
par(mfrow=c(2,1))
tsplot(w, main="white noise")
tsplot(v, ylim=c(-3,3), main="moving average")

Autoregression

w = rnorm(550,0,1)  # 50 extra to avoid startup problems
x = filter(w, filter=c(1,-.9), method="recursive")[-(1:50)]
tsplot(x, main="autoregression")