Skip to content
Prev 3751 / 15274 Next

Locating peaks in zoo objects in one go

Dear Gabor,

Thanks for your prompt answer. One question though:

It seems to be missing the VIX peaks at the beginning and the very end of the history of the sequence.

What am I missing? I am trying to understand it from the help pages but...
 
Costas Vorlow 
 

-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] 
Sent: Thursday, March 05, 2009 6:39 PM
To: Vorlow Constantinos; costas at vorlow.org
Cc: r-sig-finance at stat.math.ethz.ch
Subject: Re: [R-SIG-Finance] Locating peaks in zoo objects in one go

This locates peaks over plus or minus (k+1)/2 days (k odd):

# VIX from post
library(zoo)
k <- 201
idx <- rollapply(VIX, k, function(x) which.max(x) == (k+1)/2)
plot(VIX)
abline(v = time(idx)[idx])
On Thu, Mar 5, 2009 at 10:00 AM, Vorlow Constantinos <CVorlow at eurobank.gr> wrote: