5

I would like to use discrete Fourier transform to identify dynamic of sales and then cluster similar patterns. However, I'm new in using R and after searching for a solution, I found a prodecure fft(), but not exactly sure if I get the same result as for DFT. I would like to present waves on a plot and then use an algorithm to cluster similar sales dynamics. What's more, I was wondering if I can use procedure fft to transform all time series, not one by one (so suggest R: transform new time series after 26 weeks - look at the database)

http://imageshack.com/a/img854/1958/zlco.jpg piece of my database; three 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

http://imageshack.com/a/img703/6726/sru7.jpg that's how my time series looks like

I believe that I can use fft() to eventually accomplish this goal however the leap from the output of fft() to my goal is a bit unclear.

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 w.r.t. putting the output of fft() in context, or any package you could recommend that would accomplish this task efficiently would be appreciated

user3463225
  • 401
  • 9
  • 19

1 Answers1

1

From ancient memory you should square the real part to get the spectrum which gives you the magnitude at each frequency (days in your example)

x = some data
plot(Re(fft(x))^2)
user3472874
  • 151
  • 5
  • Some data mean one column which is on y axis or time? Cause I want FFT to consider sales_gain for each product category in every week and get the results (vectors/points) which I can cluster after that. And each cluster is supposed to show me the group of product with different dynamic of sales. Should I count FFT for each time series separately? I would be grateful for a detailed examplanation – user3463225 Mar 28 '14 at 17:39
  • After using x=dane$sales_gain plot(Re(fft(x))^2 I got this plot. Could you tell me what it means? http://imageshack.com/a/img856/5883/jzsy.jpg Is it the frequency for each observation? Cause I need to analyze time series, so probably I should get frequencies of sales_gain for each week for products – user3463225 Mar 28 '14 at 17:48
  • Sorry - just noticed these messages. – user3472874 Mar 31 '14 at 14:43
  • The dft converts your signal from a time domain to a frequency domain. Along the x axis is your frequency and the y is the intensity. The fft is just an algorithm to compute the dft but much more quickly. Looking at your data I might be tempted to ask why you are starting with a dft. It might be better modeled using some time series methods where you can create certain variables (dayofweek, weekday/weekend etc.) and look for trends or seasonal patterns in the data. R has a brilliant package for this kind of thing http://cran.r-project.org/web/packages/forecast/index.html – user3472874 Mar 31 '14 at 14:59
  • @user3472874 Can I ask a question, because I also new in R and FFT, so you mean intensity in y axis is magnitude? because I sow the concept of FFT any magnitude and phase, but actually i am still not understand . And then the second is could you tell me why we need to power with number 2. Thank you for your answer – rischan Aug 06 '14 at 08:56