Drop and Gain Clustering

I decided to build on John Hussman’s clustering of large moves research. As demonstrated in a previous post we showed how large drops -3% seemed to cluster. This time I superimposed the gains to see if there was a similar pattern the gain behaviour and as you can clearly see there is. My takeaway is volatility begets volatility, but where is the start and the finish? (subject for another time)

```---
title: "Drop and Gain Clustering"
author: "Michael Berman"
date: "Thursday, October 30, 2014"
output: html_document
---

require(quantmod)
require(PerformanceAnalytics)

#get the data of S&P500
getSymbols('SPY', from='1990-01-01')

#lets look at it from 1990 to 2015
spy <- SPY['1990/2015']

#our baseline, unfiltered results
ret <- ROC(Cl(spy))

#our comparision, filtered result
filter.d <- Lag(ifelse(ret < -0.02, 1, 0))
drops<- rollapply(filter.d==1,100,sum)
filter.g <- Lag(ifelse(ret > 0.02, 1, 0))
gain<- rollapply(filter.g==1,100,sum)

#two versions of plots - A
plot(gain, main = "Drop and Gain Clustering", sub = "sum of 2% movements over 100 prior days")
par(new=T)
plot(drops, main = "Drop and Gain Clustering", labels = FALSE, col = "red")

# plots - B
plot(drops, main = "Drop and Gain Clustering", sub = "sum of 2% movements over 100 prior days", ylab ="drops")
par(new=T)
plot(gain, main = "Drop and Gain Clustering", labels = FALSE, col = "red")
axis(side =4)
mtext("gains", side = 4)```

Created by Pretty R at inside-R.org I am actually not sure of which one is a better way to look at it. 