Skip to content

Instantly share code, notes, and snippets.

@jfreels
Last active December 17, 2015 14:18
Show Gist options
  • Save jfreels/5622926 to your computer and use it in GitHub Desktop.
Save jfreels/5622926 to your computer and use it in GitHub Desktop.
Drought table example
### Drought
### A drought is a flat period in performance.
### The max drought is the longest flat period in a track record.
### The current drought is the current flat period in a track record.
require(devtools)
install_github("r_jfreels","jfreels")
# load data
require(PerformanceAnalytics)
data(edhec)
edhec<-data.frame(date=index(edhec),coredata(edhec))
edhec<-melt(edhec,id.vars='date')
edhec<-data.table(edhec,key=c('variable','date'))
# max drought table
jf.table.drought(edhec,type='max')
# current drought table
jf.table.drought(edhec,type='current')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment