DMelt:Finance/Time Series

From jWork.ORG
Jump to: navigation, search
Limitted access. Reguest membership or login to this link first if you are already a member

Time series

DataMelt can read data (time series) in variety of formats, such as ASCII, Gauss and Matlab. One can read and write data in Microsoft Excel 97 formats (the extension "xls"). Data can be modified, showed as tables, plotted. Also, a statistical analysis can be performed. One can also save such data into ASCII, Gauss, Matlab,

You can read a number of example files into the time-series class. DMelt supports many file formats. Examples of supported files are located in the financial file format directory.

Time series data formats

Data for time series are represented using the JMulti convention.

Please read very good book Applied Time Series Econometrics.

Plotting time series

Here is a result of the output of the above code which reads time series:

DMelt example: Read time series and plot it

Often, you would like to replace the labels of the X-axis so they will show the actual time. This trick was discussed in man:visual:plot_styles. Below you can find an example which makes the actual replacement:

Descriptive statistics

One can do a full-scale analysis of time series using many powerful methods described below. Here is a 6-line Python macro which extracts one column from a data series and performs a detailed statistical analysis:

The output of this short script is given below. As you can see, it prints mean,. RMS, variance, Standard deviation, min and max values, Skewness, kurtosis and high order moments:

Size: 88
Sum: 79317.60942234722
SumOfSquares: 7.490318884164342E7
Min: 0.0   
Max: 961.765709811429
Mean: 901.3364707084911
RMS: 922.5901584523979
Variance: 39210.743676671525
Standard deviation: 198.0170287542754
Standard error: 21.10868619051051
Geometric mean: 0.0
Product: 0.0
Harmonic mean: 0.0
Sum of inversions: Infinity
Skew: -4.275748299773066
Kurtosis: 16.51526905197178
Sum of powers(3): 7.074101996131584E10
Sum of powers(4): 6.681632756449685E13
Sum of powers(5): 6.3115221764760856E16
Sum of powers(6): 5.962464385763685E19
Moment(0,0): 1.0
Moment(1,0): 901.3364707084911
Moment(2,0): 851172.6004732207
Moment(3,0): 8.038752268331345E8
Moment(4,0): 7.592764495965552E11
Moment(5,0): 7.172184291450098E14
Moment(6,0): 6.7755277110950963E17
Moment(0,mean()): 1.0
Moment(1,mean()): -5.6843418860808015E-14
Moment(2,mean()): 38765.16704398216
Moment(3,mean()): -3.3198598540862594E7
Moment(4,mean()): 3.0004383082685673E10
Moment(5,mean()): -2.704012982455758E13
Moment(6,mean()): 2.4372448867975816E16
25%, 50%, 75% Quantiles: 933.6877992686658, 945.85509828759, 949.9494485185958
quantileInverse(median): 0.5056818181818115

Time series analysis

Time series can be analyzed in many different approaches by extraction columns and rows of the data. In particular, you can construct autocorrelation and cross-correlation vectors. and plot them. One can also perform Gaussian filtering and detect peaks using a peak finder algorithm.

Time series transformations

Time series can be transformed using an analytic functions. Essentially, you can construct a function of any complexity using functions using the same syntax as for 1D functions jhplot.F1D. Find below a stript which transforms the first column of the time series container using the function $1+\sqrt(x)$


To show an column as a histogram is a convenient way to sudy the properties of time series. Below we show how to convert a column to jhplot.H1D histogram and show it on the canvas:

The output of this code is shown below.

More information on this topic is in DMelt books