# Time series comparison

Hi,

I have simple time series that look like this:

Graph is consisted of four categories that are represented as lines, something like this (ignore horizontal blue line, it is just a threshold):

As you can see lines are usually aligned, but from time to time we have situations like these:

One lines goes far away from other three

One line is in opposite direction from others

Two lines fell down

What would be the logic for the best approach to diagnose such misalignments?

At the moment, my colleague is using median of the four categories values and then comparing each category value to the median. If category value is above or below threshold – that is the signal for misalignment.

I believe there is a better way, maybe correlation or np.linalg.norm, for example.

Does someone here have a better idea?

Regards.

Views: 995

### Replies to This Discussion

I'm not sure what you mean by wanting to diagnose the misalignment but if you're trying to break up the time series data into separate groups, have you tried k-means clustering?

Hi,

well, I don't need clustering because I already have groups. Each line is a group. I have to conclude relations between groups. After researching a little bit, I am using tukey hsd test. I have imported:

from statsmodels.stats.multicomp import pairwise_tukeyhsd
from statsmodels.stats.multicomp import MultiComparison

and than I am using pandas dataframe as source:

mc = MultiComparison(df.WBPerc, df.WBGroup)
result = mc.tukeyhsd()

For example, if groups look like this:

Tukey HSD reports:

Which meand group N-A is not the same as groups "Wideband-Cable5/0/0:0" and "Wideband-Cable5/0/0:1" (reject null hypothesis). Ahpha level is default 0.05.

This is another example, orange is above others:

As you can see null hypothesis is always rejected if one of the groups is "Wideband-Cable2/0/2:1", which is true.

I am not sure is Tukey HSD method a good approach.

Regards.

I'm not sure what you mean by wanting to diagnose the misalignment but if you're trying to break up the time series data into separate groups, have you tried k-means clustering?