[R] How to do a moving window on standard deviation
Pete Brecknock
Peter.Brecknock at bp.com
Sun Jan 30 23:48:18 CET 2011
I believe there are two reasons why your code doesn't work
1. You should replace
sd(Close[i]:Close[(i-3)])
with
sd(Close[(i-3):i]).
This will ensure you select the appropriate obsevations to feed in the sd
function.
2. Per Ray's point above, you need to output the calculated value of sd for
each value of the loop
The code I supplied previously should work for you.
--
View this message in context: http://r.789695.n4.nabble.com/How-to-do-a-moving-window-on-standard-deviation-tp3247566p3247754.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list