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 value0
or1
. took datab
ten days later, can assign value10
or11
it. took datac
thirty days later, can assign value30
or31
it. numerical values ofa, 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.
on first column row 2 row 8, have values of
a,b,c,...
put1,2,3, ...
on second column, have data.
on third column, multiplied each cell in first column corresponding cell in second column.
on fourth column, squared value of cell of first column.
on row 10, added values of above columns.
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
Post a Comment