Purpose
When I ran the pairs model on Feb 3rd 2010 data, there were 33 pairs that showed mean reversion. One nagging question though, is , does the spread behavior shown any seasonality effect ?

ANOVA , a concept which is well forgotten after stepping out of stats lectures, is probably a great tool in understanding the seasonality effect.

Lets build a dataframe with the relevant variables

> pairs <- data.frame(with(filtered.pairs, cbind(longt, shortt,
+     spread.id)))
> colnames(pairs) <- c("longt", "shortt", "spread.id")
> pairs.residuals <- data.frame(matrix(data = NA, nrow = dim(spreads)[1],
+     ncol = 33))
> for (i in 1:33) {
+     pairs.residuals[, i] <- spreads[, pairs$spread.id[i]]
+ }
> query <- paste(" select distinct( trade_date ) from security_prices ",
+     sep = "")
> dates <- dbGetQuery(con, query)
> dates <- dates[1:241, 1]
> pairs.residuals$dates <- dates
> pairs.residuals$month <- (1 + as.POSIXlt(pairs.residuals$dates)$mon)

At this point in time, I have a dataframe with residuals for each of the 33 pairs. I also have the month number attached to each of the months.

What do I need to do now ? I am going to do it for one pair. I will separate the spread increments for each day and categorize as per the month they fall under. After that I am going to check for the seasonality of the spread increments across month.

Meaning, I will end up x1, x2, x3 …., x12 values for each of the months. I will then do an anova pair wise But to make it easier, I will use TukeyHSD which spells out comparisons for each pair.

> pairs.final.residuals <- pairs.residuals
> pairs.final.residuals <- pairs.final.residuals[-1, ]
> for (i in 1:33) {
+     pairs.final.residuals[, i] <- diff(pairs.residuals[, i])
+ }
> z <- pairs.final.residuals[, c(1, 35)]
> z[, 2] <- factor(z[, 2])
> comparison <- TukeyHSD(aov(z[, 1] ~ z[, 2]))
> head(comparison$z, 5)
         diff       lwr      upr     p adj
2-1 1.7469694 -3.382647 6.876586 0.9932976
3-1 0.4542984 -4.545433 5.454030 1.0000000
4-1 1.3235931 -3.880912 6.528098 0.9995172
5-1 1.4667102 -3.533021 6.466442 0.9981828
6-1 0.5318865 -4.359011 5.422784 0.9999999

So, one needs to always remember that seasonality for any variable can easily be checked by doing an anova. Using anova, one can see the pair wise comparisons of mean, upper and lower bands for the pair wise comparisons. These intervals will give an idea about the confidence intervals that you can attach to the difference between the mean for the variable for a specific pair of months.