5
$\begingroup$

I have time series of parameters A, B, C and D. All of them are under influence of the same major conditions, but each one has minor differences. They are placed in different locations, A, B, C are in local1 and D is in local2.

I would like to know which one (A, B, C) has the major similarity to D. How should I approach this issue?

$\endgroup$
  • $\begingroup$ What do you mean by "similarity" here? Can you define it mathematically? $\endgroup$ – Spacedman Dec 20 '16 at 8:18
  • $\begingroup$ Well, I don't have a math definition in hand right now. May I ask I guidance on this? $\endgroup$ – KcFnMi Jan 2 '17 at 19:37
6
$\begingroup$

Sounds like a job for Dynamic Time Warping, there are implementations in Python and R.

| improve this answer | |
$\endgroup$
4
$\begingroup$

There are many ways in which you can compute a distance between time series, and the method to use will depend on your data.

As stated by other answers, Dynamic Time Warping may be the way to go. However, this method assumes that there may be a non-linear warp between different parts of the time series.

If you are not expecting warping or delays in the signal, something as simple as Euclidean distance may be a better way to go. Of course, you should apply Euclidean distance only after you applied some preprocessing (for instance, amplitude scaling).

Take a look to this presentation, that introduces the pros and cons of these methods and discuss preprocessing in more detail:

| improve this answer | |
$\endgroup$
  • $\begingroup$ May I understand "amplitude scaling" as normalization? $\endgroup$ – KcFnMi Jan 2 '17 at 19:41
  • $\begingroup$ Since, "this method assumes that there may be a non-linear warp between different parts of the time series". What happens in case that thing (non-linear warp between different parts of the time series) didn't exist in the time series I'm dealing with? Should DTW still work? $\endgroup$ – KcFnMi Jan 2 '17 at 19:58
  • 1
    $\begingroup$ Yes, you may undestand amplitude scaling as normalization. A way of doing this is by substracting the average value to each time series and then dividing each one by the width of the range of amplitude values If non-linear warp does not exist DTW may still work, but that would depend on your data. What I would suggest is for you to try both methods (DTW and euclidean), and visualize the results so that you can determine which one works better in your specific case. $\endgroup$ – Pablo Suau Jan 3 '17 at 10:25
  • 1
    $\begingroup$ Upvote for the awesome presentation you shared :) thanks. $\endgroup$ – Mannu Jul 14 '18 at 5:00
3
$\begingroup$

First, you should define what you mean with similarity and a corresponding metric to measure it. The second step is to apply the metric to (A, D), (B, D), etc. Then, the set that gives the smallest value is the one with the highest similarity. If you find that your metric does not what you want, simply change it until it meets your requirements. You need to be clear about what you mean with "similarity" and how to measure it though.

One possibility is to interpret the sets of parameters as a point in a N-dimensional space and calculate the average euclidean distance.

| improve this answer | |
$\endgroup$
0
$\begingroup$

You could just check the RMSE between A, B,C to D and take the minimal one.

| improve this answer | |
$\endgroup$
0
$\begingroup$

In addition to the provided methods, I have found Pearson Correlation Coefficient (also mentioned in this answer) and Cosine Similarity metrics to be useful in this scenario.

In practice, Pearson Correlation Coefficient seems to be better than Cosine Similarity though. The reason is that Pearson Correlation Coefficient is invariant to scaling of a series (~adding a constant).

Here is a little proof:enter image description here

If you take a look at the output [17], cosine similarity decreases when we add a constant to the original series! On the other hand in output [18], the Pearson correlation coefficient values do not change to scaling. For this reason, in my case, I have decided to go with the Pearson Correlation Coefficient.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ Following @Pablo Suau's answer, to note that both Pearson correlation and cosine similarity implicitly assume that there's no lag etc. between the time series. $\endgroup$ – Itamar Mushkin Aug 19 at 7:43
  • $\begingroup$ @ItamarMushkin yes indeed! As I understand, Dynamic Time Warping (DTW) comes in handy in this case? $\endgroup$ – Bilguun Aug 20 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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