[R-SIG-Finance] Standard Deviations using Sliding window?
Robert Nicholson
robert.nicholson at gmail.com
Sun Mar 7 03:15:49 CET 2010
currently using rollapply with sd so I assume that will do the same as runSD
On Mar 5, 2010, at 9:23 AM, Joshua Ulrich wrote:
> On Thu, Mar 4, 2010 at 8:15 PM, Robert Nicholson
> <robert.nicholson at gmail.com> wrote:
>> Here was a naive attempt to do standard deviation with sliding window
>>> require(quantmod)
>>> getSymbols("AAPL")
>>> AAPL$STDDEV = sd(Cl(AAPL), 20)
>>> AAPL$SMA = SMA(Cl(AAPL), 10)
>>> AAPL
>>
>> apparently sd doesn't work with a sliding window where was SMA does so it seems
>
> No, sd doesn't work with a sliding window, but there's nothing in ?sd
> to indicate that it would.
>
>> I need to look at SMA to see how the sliding window code is handled and write my
>> own sd that uses a sliding window?
>>
> Yes, or you can just use the runSD function in TTR. ;-)
>
>> the SD columns up the same for all rows which isn't what I want.
>>
> but that's exactly what it's documented to do...
>
> Best,
> Josh
> --
> Joshua Ulrich
> FOSS Trading: www.fosstrading.com
>
>> _______________________________________________
>> R-SIG-Finance at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions should go.
>>
More information about the R-SIG-Finance
mailing list