Preamble

library("forecast")
library("rugarch") # ARCH/GARCH models
Loading required package: methods
Loading required package: parallel

Attaching package: 'rugarch'
The following object is masked from 'package:stats':

    sigma

General Motors Returns

Daily GM Returns (September 1, 1987 - November 30, 1987)

data <- read.csv("http://ptrckprry.com/course/forecasting/data/gm.csv")
date <- as.Date(data$date)
time <- seq_along(date)
ret.GM <- data$GM   # daily return

Daily Returns

plot(date, ret.GM, xlab="Date", ylab="Daily Return", type="l", col=2)
crash <- which(date == "1987-10-19")
text(date[crash], ret.GM[crash], "Oct 19, 1987")

Before and After Crash

boxplot(ret.GM[time < crash - 1], ret.GM[time > crash + 1],
        names=c(paste("To",   strftime(date[crash - 1], "%b %d")),
                paste("From", strftime(date[crash + 1], "%b %d"))),
        ylab="Daily Return", col=2)

Autocorrelations, Partial Autocorrelations

par(mfrow=c(1,2))
Acf(ret.GM)
Pacf(ret.GM)

Squared Returns

plot(date, ret.GM^2, xlab="Date", ylab="Sq. Return", type="l", col=2)