1
$\begingroup$

I have a time series dataset as follows

day                1     2      3     4      5     6

sales_dept1        0     0      0     3      3     3
sales_dept2        0     0      0     6      6     6
sales_dept3        0     0      0     1      1     1

As you can see, dept2 is most efficient, dept1 is second most efficient and dept3 is less efficient.

In other words, I want to capture the performance diffrences among the departments.

For, that I used Linear Regression and got the slope as a metric to compare the performace. However, I got the following results as the slope (which do not match with my manual interpretation).

dept1 slope = 1
dept2 slope = 0.5
dept3 slope = 3

My code is as follows.

from sklearn.linear_model import LinearRegression
regressor = LinearRegression()

X = [[0], [0], [0], [3], [3], [3]]
y = [1, 2, 3, 4, 5, 6]
regressor.fit(X, y)
print(regressor.coef_)

Therefore, I think slope is not the correct metric for my situation. Is there any other metric that captures the actual growth change of different time-series data?

I am happy to provide more details if needed.

Update:

Mentioned below are some more data:

[0, 0, 0, 1, 1, 1]
[6, 6, 6, 6, 6, 6]
[0, 0, 0, 0, 0, 10]
[0, 3, 3, 28, 30, 30]
[0, 0, 0, 6, 6, 6]
[0, 0, 0, 0, 0, 10]
[0, 0, 0, 0, 1, 1]
[6, 6, 6, 6, 6, 6]
[0, 0, 0, 0, 1, 1]
[0, 0, 0, 6, 6, 6]
[0, 1, 1, 4, 4, 4]
[3, 19, 19, 47, 64, 90]
[0, 0, 3, 8, 13, 13]
[0, 3, 3, 3, 3, 3]
[0, 0, 0, 6, 6, 6]
[0, 0, 0, 0, 0, 6]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 10]
[0, 0, 0, 0, 0, 6]
[10, 10, 10, 10, 10, 10]
[0, 0, 0, 0, 10, 10]
[0, 0, 0, 7, 7, 15]
[0, 0, 0, 0, 10, 10]
[6, 6, 6, 6, 9, 9]
[6, 6, 6, 6, 6, 6]
[0, 0, 3, 3, 3, 3]
[0, 0, 0, 6, 7, 7]
[0, 3, 4, 4, 4, 4]
[0, 0, 0, 0, 1, 1]
[3, 3, 3, 3, 3, 9]
[0, 0, 6, 6, 6, 6]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 6, 6, 6]
[1, 1, 1, 1, 1, 1]
[0, 0, 0, 15, 15, 15]
[0, 15, 15, 15, 15, 15]
[0, 0, 0, 0, 0, 0]
[0, 1, 1, 1, 1, 1]
[0, 0, 1, 1, 1, 1]
[0, 15, 16, 22, 32, 68]
[0, 0, 0, 1, 1, 1]
[0, 0, 0, 0, 1, 1]
[0, 3, 3, 4, 4, 4]
[0, 0, 0, 15, 15, 15]
[0, 0, 0, 0, 0, 10]
[0, 0, 0, 21, 21, 21]
[0, 0, 0, 6, 6, 6]
[0, 0, 0, 9, 9, 24]
[0, 0, 0, 3, 3, 3]
[0, 0, 0, 0, 6, 6]
[0, 3, 3, 3, 3, 3]
[0, 0, 11, 11, 19, 19]
[3, 18, 18, 43, 50, 76]
[0, 0, 0, 0, 0, 15]
[0, 0, 0, 0, 0, 0]
[14, 14, 14, 39, 42, 72]
[6, 6, 6, 6, 6, 6]
[0, 0, 0, 0, 3, 3]
[0, 0, 0, 0, 0, 3]
[0, 0, 0, 0, 6, 6]
[0, 0, 0, 15, 15, 15]
[0, 0, 6, 6, 6, 6]
[0, 0, 10, 10, 10, 10]
[0, 0, 6, 6, 6, 6]
[0, 0, 10, 10, 13, 13]
[0, 0, 0, 6, 11, 11]
[6, 6, 6, 6, 6, 6]
[0, 0, 0, 0, 3, 3]
[0, 0, 0, 0, 0, 0]
[10, 10, 10, 10, 10, 28]
[0, 0, 0, 6, 6, 6]
[0, 0, 0, 15, 15, 15]
[0, 0, 0, 0, 1, 1]
[0, 0, 0, 0, 0, 10]
[1, 1, 1, 1, 1, 1]
[0, 0, 0, 6, 6, 6]
[0, 0, 0, 21, 21, 21]
[0, 0, 0, 0, 0, 15]
[0, 0, 0, 0, 0, 6]
$\endgroup$
  • 1
    $\begingroup$ You want to capture performance differences among the departments. What do you mean by good performance? Faster growth than others? (slope of a deterministic linear trend measures it, but is the trend linear?) Or higher average sales? Anyway six day is really few to speak about any kind of trend. $\endgroup$ – oszkar Mar 20 at 10:57
  • $\begingroup$ @oszkar thanks for the comment. we do weekly analysis. that is why I only have 6 days :( do you have any suggestions? yes, I want to identify what departments are faster growing than other departments. Looking forward to hearing from you :) $\endgroup$ – Emi Mar 20 at 12:22
  • $\begingroup$ @oszkar It is not simply the # of observations but rather the ratio of signal to noise. A 6 valued series 1,2,3,4,5,6 speaks to a trend . 1,1,1,3,3,3 speaks to a change in level/step ... 1,2,1,2,1,2 speaks to a pattern ... 1,1,1,1,1,2 speaks to a pulse,... As usual of these examples/conclusions may be "proven" to be right or wrong as future values become known. $\endgroup$ – IrishStat Mar 20 at 17:25
  • $\begingroup$ @EMI If you have more data please modify your post to include all data to date. $\endgroup$ – IrishStat Mar 26 at 12:53
1
$\begingroup$

.Trends can be of two forms y(t)=y(t−1)+θ0 (A) Stochastic Trend or Y(t)=a+bx1+cx2 (B) Deterministic Trend etc where x1=1,2,3,4....t and x2=0,0,0,0,0,1,2,3,4 thus one trend applies to observations 1−t and a second trend applies to observations 6 to t. Often software is needed to aid the detection of the trend changes.

If you post a real series I may be able to help you further.

Trend shifts in timeseries provides some insight/guidance .

Apparently you are tracking some 79 items over time ( currently 6 days )

In the future please attach an external csv file to your post reflecting the total history of the 79 items in the form presented here for ease of analysis.

enter image description here

For example I took series 11 and obtained enter image description here enter image description here

EDITED AFTER OP'S QUESTION AS TO HOW THIS GRAPH WAS DRAWN:

After considering two options :

1) Build a model using a PREDICTOR SERIES of the form 1,2,3,4,5,6

2) Build a model optimally using the history of prior values (ARIMA)

the tournament ( i.e. set of trials) concluded the the best model was 2) which meant that the prediction at any one point would be to use the most recent value and add 17.4 . The graph shows the Actual and the 1 period out prediction at each point in time IN GREEN.

I have taken your 79 series of length 6 and created 79 png files showing the actual and the fitted/predicted values which represent the equation . If you contact me at dave@autobox.com , I will be happy to send them to you along with the companion equation files. I just don't know how to attach them to this post.

$\endgroup$
  • $\begingroup$ Thanks a lot. I only have the data for 6 days. I will post more data now. Looking forward to hearing from you. :) $\endgroup$ – Emi Mar 20 at 6:55
  • $\begingroup$ I updated the question. Please let me know your thoughts. Thank you very much once again :) $\endgroup$ – Emi Mar 20 at 7:00
  • $\begingroup$ thanks a lot for the update. However, I am still not clear how this graph is drawn. Can you please tell me some details about the method you used? :) $\endgroup$ – Emi Mar 20 at 12:20
  • $\begingroup$ thank you very much for the update :) $\endgroup$ – Emi Mar 20 at 15:54
1
$\begingroup$

I would do the next for a fast and simple solution:

  1. Iterate through the departments, calculate the slop of the linear regression.
  2. Create groups/clusters from the slopes to have performance groups. You can apply some cluster analysis, some initially set thresholds, or just a check the results and use common sense. For some automated solution the first two approach could be use.

(Later will add some example code to show what I mean.)

$\endgroup$
  • $\begingroup$ thank you very much. However, as I have mnetioned in the question regression slope did not give me the output I expected. Looking forward to hearing from you :) yes, it would be really helpful if you could add some example code. Thank you very much once again :) $\endgroup$ – Emi Mar 20 at 13:21
  • 1
    $\begingroup$ @Emi Will check that too. $\endgroup$ – oszkar Mar 20 at 13:40
  • $\begingroup$ thanks a lot. i look forward to hearing from you :) $\endgroup$ – Emi Mar 20 at 15:54
  • $\begingroup$ If there are multiple trend changes or level/step changes or pulses or autoregressive structure in the data your suggestion of using the slope of a simple linear regression on time is way to simple and ignores the work of time series analysts for the last 60 years $\endgroup$ – IrishStat Mar 22 at 0:38
  • $\begingroup$ @IrishStat As far as I get it right no trend changes was in question: "yes, I want to identify what departments are faster growing than other departments". (The "growth of a trend" part in the title could be misleading.) As far as I understand, it want to be measured within a week. But Emi will clear that. $\endgroup$ – oszkar Mar 26 at 8:41

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.