I'm using package dtw (R) to compare subsets of a price time-series. I have 100 observations through which I loop a rolling window and extract subsets of 5 consecutive observations. I thus obtain multiple equal subsets of my data.
> head(data_xts[,4]) Close 2015-06-01 00:00:00 0.88337 2015-06-01 00:01:00 0.88375 2015-06-01 00:02:00 0.88412 2015-06-01 00:03:00 0.88394 2015-06-01 00:04:00 0.88380 2015-06-01 00:05:00 0.88393
I now want to compare the line resulted from the above subset with another subset from the same list
f <- dtw(input, input2, step=asymmetricP1, keep=T)
The question is: As Prices increase or decrease (as they do) if I compare the price line of my first 5 periods with that of the last 5 periods i have lines on a different scale. is scale an issue? and if yes should I standardize my data first?
I have three options:
I calculate the % difference between observations prior to subsetting. i.e % return. Then I subset into consecutive periods of 5.Then simulate a USD = 1 investment in that 5 period return to generate a new line. Thus my scale always starts from USD = 1.
I normalize all values across the 100 periods using Z score and then split.
I normalize all values using Z score after splitting on individual subsets of 5. I thus use the standard deviation and mean of each subset in the calculation instead of the total.