The newest release of daru brings alongwith it added support for time series data analysis, manipulation and visualization.
A time series is any data is indexed (or labelled) by time. This includes the stock market index, prices of crude oil or precious metals, or even geo-locations over a period of time.
The primary manner in which daru implements a time series is by indexing data objects (i.e Daru::Vector or Daru::DataFrame) on a new index called the DateTimeIndex. A DateTimeIndex consists of dates, which can queried individually or sliced.
A very basic time series can be created with something like this:
1 2 3 4 5 6 7
In the above code, the
DateTimeIndex.date_range function is creating a
DateTimeIndex starting from a particular date and spanning for 1000 periods, with a frequency of 1 day between period. For a complete coverage of DateTimeIndex see this notebook. For an introduction to the date offsets used by daru see this blog post.
The index is passed into the Vector like a normal
Statistics functions and plotting for time series
Many functions are avaiable in daru for computing useful statistics and analysis. A brief of summary of statistics methods available on time series is as follows:
||Calculate Moving Average|
||Calculate Moving Median|
||Calculate Moving Standard Deviation|
||Calculate Moving Variance|
||Calculate Moving Maximum value|
||Calcuclate moving minimum value|
||Calculate moving non-missing values|
||Calculate moving sum|
||Calculate exponential moving average|
||Moving Average Convergence-Divergence|
||Calculate Autocorrelation Co-efficients of the Series|
||Provide the auto-covariance value|
To demonstrate, the rolling mean of a Daru::Vector can be computed as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
This time series can be very easily plotted with its rolling mean by using the GnuplotRB gem:
1 2 3 4 5
These methods are also available on DataFrame, which results in calling them on each of numeric vectors:
1 2 3 4 5 6 7 8 9 10
In a manner similar to that done with Vectors above, we can easily plot each Vector of the DataFrame with GNU plot:
1 2 3 4 5 6 7 8 9 10 11 12 13
Usage with statsample-timeseries
Some examples with working examples of daru and statsample-timseries are coming soon. Stay tuned!