math - Calculate if trend is up, down or stable -


i'm writing vbscript sends out weekly email client activity. here sample data:

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

since email, don't want chart trend line. need simple function returns "up", "down" or "stable" (though doubt ever stable).

i'm terrible math don't know begin. i've looked @ few other questions python or excel there's not enough similarity, or don't have knowledge, apply vbs.

my goal simple this:

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

if there delta or percentage or other measurement display helpful. want ignore outliers. instance, 646 above. of our clients not open on weekend.

first of all, data listed

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

to trend line need assign numerical values variables a, b, c, ...

to assign numerical values it, need have little bit more info how data taken. suppose took data a on 1st january, can assign value 0 or 1. took data b ten days later, can assign value 10 or 11 it. took data c thirty days later, can assign value 30 or 31 it. numerical values of a, b, c, ... must proportional time interval of data taken more accurate value of trend line.

if taken in regular interval (which case), lets every 7 days, can assign in regular intervals a, b, c, ... ~ 1, 2, 3, ... beginning point entirely choice choose makes easy. not matter on final calculation.

then need calculate slope of linear regression can find on this url need calculate value of b following table.

enter image description here

  1. on first column row 2 row 8, have values of a,b,c,... put 1,2,3, ...

  2. on second column, have data.

  3. on third column, multiplied each cell in first column corresponding cell in second column.

  4. on fourth column, squared value of cell of first column.

  5. on row 10, added values of above columns.

  6. finally use values of row 10.

            total_number_of_data*c[10] - a[10]*b[10]   b =  -------------------------------------------         total_number_of_data*d[10]-square_of(a[10]) 

the sign of b determines looking for. if it's positive, it's up, if it's negative, it's down, , if it's 0 stable.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -