# Spotting trends in time based data

I have a dataset which I need to spot trends in. The actual data refers to operation calls which take a certain amount of time to complete. My client wants to know which operation calls are improving and which are deteriorating over a time period.

Each operation call has an entry for each day which shows the average time that call took to return.

Date        Call    Avg duration
-----------------------------------
18/03/2013  Call 1  123ms
19/03/2013  Call 1  156ms
20/03/2013  Call 1  198ms
21/03/2013  Call 1  99ms


My current implementation uses

(CurrentDayAvgDuration - PrevDayAvgDuration) / √(CurrentDayAvgDuration + PrevDayAvgDuration)


for each day and then takes the average of that value over all days but I'm not too sure if the value is relevant. That formula is one I found and plugged in just to try.

My question is, how can I calculate a single value per operation call which can be used in comparison with all of the other operation calls to determine which are trending upwards (deteriorating) and which are trending downwards (improving)?

I'm not able to post a comment because of my weak reputation. A simple answer would be a moving average, you simply have to replace the duration of the call by the mean duration of the last p call. You'll choose p empirically, by plotting the results, high enough to remove noise, low enough to observe something. You should be able to observe the trend by plotting your new time serie

If you want a single value you should try: short term mean - longer term mean. The definition of short term and long term depends on the process (noise, seasonality ... ect), the way it evolves, the number of data you have, the frequency at wich your client ask for this information.

For exemple, if your client ask for it every month you should take: short term: 1 month long term: 12 month

if your client ask for it every week: short term: 1 week long term: 1/2/3 month

So the progress will be easy to show to your client: over last month the call duration improved by xxms from last year.

• Thank you, I ended up going with a single value based on short term mean - long term mean as you suggested. I need to alter the definition of long term based on what the client inputs as short term before I can get reliable data, but it looks like this will work just fine. Mar 27, 2013 at 10:28
• Actually, one question. Should the long term range include the short term range? For example, say I want 1st March - 8th March as my short term and I want my long term to be 1 month. Would my long term be 8th Feb - 8th March or 1st Feb - 31st Feb Mar 27, 2013 at 10:42
• Well, in my opinion it's better if the long term range doesn't include the short one, the information is clearer. But In my company we often use long term range including short term range because it's simpler for us and the client. For exemple, if you use the second method you will have to handle variable such "mean over last year excluding front week" and/or "mean over last year shifted by 1 week" and/or "mean over last year excluding front month" and/or "mean over last year shifted by 1 month". As you can see "mean over past year" is way simple/clear. Mar 27, 2013 at 10:50
• That's great, thanks for your help and I'm glad to see that you now have enough rep to post comments :) Mar 27, 2013 at 11:35

I partially agree to Imorin's comment. But if you are interested in a trend, you must consider rates of change over a moving window. If the Averages are successively decreasing/increasing, then it must indicate improved/deteriorated performance.

You must also select a threshold based on historical records as to lowest/highest values of rates indicating a significant step towards improvisation or deterioration.