What is partial autocorrelation?

This is the final post I have planned in the autocorrelation series. I’ll introduce a new concept called partial autocorrelation and show a couple examples of the concept in action. We’ll learn some important things about the stock market.

Without getting into the math, here’s a couple definitions you should commit to memory:

  1. Autocorrelation (“ACF”) measures the correlation between observations in a time series and observations a fixed unit of time away.
  2. Partial autocorrelation (“PACF”) measures the correlation between observations in a time series and observations a fixed unit of time away while controlling for indirect effects.

For example, here’s both ACF and PACF for monthly U.S. unemployment.
unem

This is a common pattern you’ll see in the field often: a slow decay of ACF, and a spike in PACF. Starting at a lag of two months, PACF is basically zero.

This means that January’s unemployment influences March’s unemployment, but only because January influences February and February influences March. If unemployment were high in January and low in February, we would predict March’s unemployment to also be low.

In the Box-Jenkins methodology, ACF and PACF plots like this one are used to determine the correct model. Applying this step to a preexisting model will address seasonal patterns in residuals.

A few notes:

  1. The unemployment rate I analyzed was already seasonally adjusted. Because there are seasonal patterns in employment (Christmas is like Christmas), it would have shown a spike in the 12 month lag if we had used the non-seasonally-adjusted data.
  2. Note that for a lag of one, autocorrelation is equal to partial autocorrelation.
  3. Sometimes, there will be a spike in PACF and a slow decay in ACF.  Sometimes there will be spikes in both ACF and PACF.
  4. Both ACF and PACF can be negative. For instance, getting little sleep tonight might predict getting extra sleep tomorrow night.
    • I tested this on my sleep data (recorded using the UP band), and ACF and PACF were both equal to zero for my data, but I also averaged 5.64 hours/night, so I’m probably not a standard sleeper.

In a previous post, we noticed autocorrelation in the GTA stock market. Invest in stocks that are currently rising because they’ll probably continue rising.

Unfortunately, the same logic does not hold true for the real life stock market. Alas. Here’s the same graph for the daily returns of a few companies:

F

DLR

AAPL

This result is consistent across the stock market. Yesterday’s return tells you nothing about how a stock will act today. Many investors are tempted to think about stocks in terms of “mean reversion” or a stock being “hot.” Based on daily returns, there is no evidence for this view.

All these graphs were produced using R, a statistical programming language. Here’s the R code that generated the data for the first table:

#Load required Mods
require(quantmod)

#Import Data. Trim unused rows.
unemp <- getSymbols(“UNRATE”, src = “FRED”,auto.assign=FALSE)

#Specify lags
lags<-20

#Compute autocorrelation and partial autocorrelation.
macf <- acf(unemp,type=”correlation”,plot=FALSE,lag.max=lags)$acf[-1]
mpacf <- acf(unemp,type=”partial”,plot=FALSE,lag.max=lags)$acf

#Create and populate results table
Rtable <- matrix(c(1:lags,macf,mpacf),nrow=lags,ncol=3)
colnames(Rtable) <- c(“Lag”,”Autocorrelation”,”Partial Autocorrelation”)

#Output Table to csv
write.csv(Rtable,file = “corrtable.unemp.csv”, row.names=FALSE)