Created
March 8, 2016 19:37
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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