1
$\begingroup$

For time series data analyzing peaks depends on the time window by which the data is segregated. Is there a way to determine an optimum window size? For example, for the purpose of my problem I need to compute the importance of a peak in a time series. I am calculating the fraction of mentions observed on the peak day divided by the total cumulative mentions over a span of 7 days (termed as peak fraction). This idea is borrowed from a research paper. However the value of peak fraction will change significantly when one changes the window size. A time series where 90% mentions happen on a single day, will have a very high peak fraction when window size is 1 day, since essentially it will have one distinct peak for that day. However, if window size is much smaller (say 1hour), the chances of getting one distinct peak is much smaller. The peak fraction is way smaller now.

Is there any empirical way or an algorithm to determine window size while analyzing peaks in time series?

Here is an example dataset. The two series are from the same time series but aggregated over different time window

Series1_60Min = c(36, 0, 0, 0, 0, 0, 0, 0, 760, 7000, 2887, 163, 70, 44, 36, 22, 25, 8, 8, 7, 6, 4, 3, 7, 5, 4, 31, 3)
Series2_1Day = c(10, 26, 11083, 10)

Peak Fraction for Series1_60Min = max(Series1_60Min)/sum(Series1_60Min) = 0.628
Peak Fraction for Series2_1Day = max(Series2_1Day)/sum(Series2_1Day) = 0.995
$\endgroup$
0

1 Answer 1

1
$\begingroup$

I would use Fourier Analysis to try to find natural cycles. Your peaks should be within those cycles. For example with your data you could estimate the spectral density using:

spct <- spectrum(Series1_60Min)

Spectral Density Estimation The maximum in the plot should be your "natural" frequency. Frequencies are expressed in terms of fractions as complete series. If your series is sampled every minute then you should choose a period between 1.86 to 2.8 minutes which is where your maximum is.

$\endgroup$
1
  • $\begingroup$ I should have mentioned that my data corresponds to tweets collected continuously. So in essence I am not doing any sampling while data collection. However, after collecting data I do need a good way to represent these as time series to analyze features of a TS (like periodicity, peak fraction). All these features will have very different value with differing time windows used for representing time series. Hence my question, how do I choose window size? $\endgroup$
    – tan
    Commented Oct 30, 2015 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.