# Fast Fourier Transform and Clustering of Time Series

I'm making a project connected with identifying dynamic of sales. That's how the piece of my database looks like:

There are free columns:

• Product - present the group of product
• Week - time since launch the product (week), first 26 weeks
• Sales_gain - how the sales of product change by weeks

In the database there is 3302 observations = 127 time series

My aim is to cluster time series in groups which are going to show me different dynamic of sales. Before clustering I want to use Fast Fourier Transform to change time series on vectors and take into consideration amplitude etc and then use a distance algorithm and group products.

It's my first time I deal with FFT and clustering, so I would be grateful if anybody would point steps, which I have to do before/after using FFT to group dynamics of sales. I want to do all steps in R, so it would be wonderful if somebody type which procedures should I use to do all steps.

Thats how my time series looks like now:

Please note that I am relatively new to time series analysis (that's why I cannot put here my code) so any clarity you could provide in R or any package you could recommend that would accomplish this task efficiently would be appreciated.

P.S. Instead of FFT I found the code for DTW here -> link
but cannot use it on my data base and time series (suggest R to analyze new time series after 26 weeks). Can somebody explain it to me?

• It's not quite clear to me what you are trying to achieve with the clustering? What are you trying to cluster? What information are you trying to get out of the data? Perhaps show us some pictures of what you envision getting out of the data. – Peter K. Mar 29 '14 at 17:56
• I want to cluster products to get groups of products with similar dynamic of sales – peterpeter Mar 29 '14 at 19:15
• It would be wonderful if I could present each cluster on the plot to see the dynamic of sales – peterpeter Mar 29 '14 at 19:23
• Can you provide us with your goal, clearly? Why do you want to use FFT? That will give you underlying frequencies/period in your signal. Also why are you trying to use Dynamic Time Warping - is there any reason for that? First you must understand what you want to achieve and clearly explain it to us, maybe then we would be able to help you to accomplish that. Pozdrawiam – jojek Mar 30 '14 at 13:38
• My main aim is to group similar products according to DYNAMICS of sales. In the plot above I have a lot of time series = sales gain of products. I want to use FFT in order to change my time series into vectors which helps me in gathering together products with similar dynamic. I understood that FFT takes peaks of different products in certain period of time and thanks to this I can analyze dynamic of sales. I'm not sure whether I understand it correctly, cause that's the first time I use this algorithm and there is no artictles connected with using FFT in sales. – peterpeter Mar 30 '14 at 15:04