Working with 30 minute data, of which I have put a sample online. It's the notional dollar value of the spread between ES and 2 contracts of NQ (ES-2*NQ). Sample is small, but should be long enough to use directly in a demo if you like. R code to grab it and use it as I am trying to:
demo.xts <- as.xts(read.zoo('http://dl.dropboxusercontent.com/u/31394273/demo.csv', sep=',', tz = '', header = TRUE, format = '%Y-%m-%d %H:%M:%S'))
head(demo.xts):
[,1]
2013-05-27 00:00:00 -37295.0
2013-05-27 00:30:00 -37292.5
2013-05-27 01:00:00 -37300.0
2013-05-27 01:30:00 -37280.0
2013-05-27 02:00:00 -37190.0
2013-05-27 02:30:00 -37245.0
What I am mainly after is a rolling window regression (or linear regression curve, as my trading platform terms it) - save it, then plot it. And, I figured to lead up to that I should be able to also plot a single simple regression for a specified time period. After the window regression, I would add standard deviation "bands" to that, but I think I can figure that one out later using TTR's "runSD" on the rolling regression. Sample of what I am after:
I think this - Rolling regression xts object in R - got me the closest to what I think I am after. It seemed to work with my data, but I couldn't figure out how to turn the resulting "coefficients" into a line or curve in the notional dollar value plot I want to work with.
Referencing any package (like TTR) would be great; happy to load anything that makes this more simple or easy.


rma + 2*runSD(demo.xts, n=20)works to add the "upper band," for example. also, the other answer by vincent seems to come up with a similar result as expected with the "lwr" and "upr" that the predict function outputs. - Paul-s