Calculate trend and represent in text?

706 Views Asked by At

First off, I'm terrible at math.

I'm writing a script that monitors transactions from clients daily over a 7 day period. Given a set of numbers like below, I would like to calculate a trend and display it textually.

a       b       c       d       e      f        g
2,780   2,667   2,785   1,031   646    2,340    2,410

I don't even know the proper terms to adequately google it myself, so I apologize. I did look at a few of Stackexchange's related questions but none of them helped.

As far as displaying it goes, I'm thinking something like ↘ %14. Honestly I would settle for just the ↘ if it is a downward trend though. Any other recommendations would be great.

p.s. There's not a trend tag so "Extrapolation" is the closest thing in my mind that related. :(

1

There are 1 best solutions below

1
On BEST ANSWER

One method can be regression, as many of others said. If you are comfort with easy math, why don't you just compare the average of a, b, c, d and the average of d, e, f, g, and then if the former is bigger then you have downward trends. If you want a percentile, $(\frac{d + e + f + g}{a + b + c + d} - 1)$ will do.

However, Saturday and Sunday is going to ruin all of this. You mentioned a trend, but trends consists of numerous factors: in your case, weekends affects your data most drastically, but I think you want to know the trend 'except' such weekend discounts.

That's not so easy task. One of the simplest methods: delete weekends data.

pros: easy.

cons: you cannot have trends data on weekends. Moreover, because weekdays also have trends(seasonal component, expert says), especially Monday and Friday, it remains still not accurate.

So what I suggest is: remove seasonal components(it's called a seasonal adjustment), then take an average as I wrote above. Seasonal Adjustment is not so easy in general, but we're not told to write a thesis paper: just go roughly.


First, prepare your weekly data for not only this week, but for n weeks, say 10, or 50. Just 2 will also works. Then take averages for each weekdays of n data.

Then you have new 7 data. For example:

           a     b     c     d     e     f     g
average 2500  2337  2435  1098   742  2200  2638

Divide your recent weekly data(I'll use the figure you included in your question) with your average data and take percentage to get:

           a     b     c     d     e     f     g
average 2500  2337  2435  1098   742  2200  2638
 recent 2780  2667  2785  1031   646  2340  2410
percent 111%  114%  114%   94%   87%  106%   91%

Then this is normalized data. now you can do whatever you want: regression or average method I wrote. For average method,

$$ \frac{d + e + f + g}{a + b + c + d} - 1 = -0.1266 \ldots $$

To get recently downward trend of -13%, for example.


By doing this method I suggest(averaging for each weekdays), you get one another intuitive information by side effect: which is the weekly performance over n weeks. if percent data(7 of them) is over 100% overall, then you may think that this week had more transactions than average. On the other hand, the opposite. May this be useless information to you, but who knows?

Good luck whatever you do.