0
$\begingroup$

I have a list of stores and the important time related variables which affect the dynamics of the store in some way or the other. The aim is to generate stores which are similar to a target store. The similarity index will be calculated based on the similarity in the trend of the variables being selected by the user.

So for example:

samp_data<-data.frame(str=c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4),week=c(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4),var1=c(13,12,18,5,3,23,32,34,3,4,5,7,8,6,54,7),var2=c(12,32,45,2,4,8,9,5,12,45,65,23,43,87,6,31))

> samp_data
   str week var1 var2
1    1    1   13   12
2    1    2   12   32
3    1    3   18   45
4    1    4    5    2
5    2    1    3    4
6    2    2   23    8
7    2    3   32    9
8    2    4   34    5
9    3    1    3   12
10   3    2    4   45
11   3    3    5   65
12   3    4    7   23
13   4    1    8   43
14   4    2    6   87
15   4    3   54    6
16   4    4    7   31

So as it can be seen that the data is at week store level, now the user can select single or multiple variables. Once the list of variables is selected, the aim is to evaluate whether the weekly data for the selected variables is similar in trend or not, if the trends are similar for the the list of variables then those stores should be displayed as similar stores.

So if user selects store 1 then some sort of similarity index or other measure should be displayed which indicates how similar other stores are as compared to this store.

Ex:

Store   Similarity Index
1
2       94%
3       80%
4       32%

Things to be noted: I cannot visually verify the trends as this is a tool which will be used by various business users. The time line for the variables will be same. Implementation will be in R

I went through existing links: Comparing 2 time series in R Proving similarities of two time series Compare two time-series

All i can find is Arima or Granger test but I dont really see how it suits my purpose.

$\endgroup$

1 Answer 1

0
$\begingroup$

If you only care about the trend similarity of the variables, you can compare variables by using the Pearson correlation coefficient:

https://en.m.wikipedia.org/wiki/Pearson_correlation_coefficient

Since you have 2 variables, you would want to combine their similarlies, so you can assign weights to each variable and if they are equally important then 0.5 can be used.

Note that the Pearson coefficient returns values between -1 (negative correlation) and 1(positive correlation) so to get a percentage, you can add 1 to the obtained value and divide by 2.

$\endgroup$
1
  • $\begingroup$ Pearson coefficient as you mentioned only takes care of the trend, I want to measure the similarity in magnitude as well. The similarity measure should be a combination of magnitude and trend. $\endgroup$
    – bakas
    Aug 18, 2017 at 8:22

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.