Skip to content

Instantly share code, notes, and snippets.

@creative-quant
Created March 8, 2016 19:37
Show Gist options
  • Save creative-quant/4946305ed9851a436ee6 to your computer and use it in GitHub Desktop.
Save creative-quant/4946305ed9851a436ee6 to your computer and use it in GitHub Desktop.
An example of finding turning points in a time series using pastecs
require(graphics)
#some data
d <- density(faithful$eruptions, bw = "sj")
#make it a time series
ts_y<-ts(d$y)
#calculate turning points (extrema)
require(pastecs)
tp<-turnpoints(ts_y)
#plot
plot(d)
points(d$x[tp$tppos],d$y[tp$tppos],col="red")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment