Page 175 - Data Science Algorithms in a Week
P. 175

Time Series Analysis


             Sales for
             November
             Year   2010     2011    2012     2013     2014     2015    2016     2017     Average
             Actual  16.9    16.5    18.7     20.5     20.4     22.4    23.7     24
             sales
             Sales on  14.0778333333 15.3568333333 16.6358333333 17.9148333333 19.1938333333 20.4728333333 21.7518333333 23.0308333333
             the trend
             line
             Difference  2.8221666667  1.1431666667  2.0641666667  2.5851666667  1.2061666667  1.9271666667  1.9481666667  0.9691666667  1.8331666667
             Sales for
             December
             Year   2010     2011    2012     2013     2014     2015    2016     2017     Average
             Actual  17.4    20.1    19.7     22.5     23       23.8    24.6     26.6
             sales
             Sales on  14.1844166667 15.4634166667 16.7424166667 18.0214166667 19.3004166667 20.5794166667 21.8584166667 23.1374166667
             the trend
             line
             Difference  3.2155833333  4.6365833333  2.9575833333  4.4785833333  3.6995833333  3.2205833333  2.7415833333  3.4625833333  3.5515833333
            We cannot observe any obvious trends in the differences between actual sales and sales on
            the trend line. Therefore, we just calculate the arithmetic means of these differences for
            every month.

            For example, we notice that sales in December tend to be higher by about 3551.58 USD
            compared to sales predicted on the trend line. Similarly, sales for January tend to be lower
            on average by 2401 USD compared to sales predicted on the trend line.

            Making the assumption that the month has an impact on the actual sales from our
            observations of the variation of sales across the months, we take our prediction rule:

            sales = 1.279*year -2557.778
            We then update it to the new rule:

            sales = 1.279*year - 2557.778 + month_difference

            Here, sales is the amount of sales for a chosen month and year in the prediction, and
            month_difference is the average difference in our given data between actual sales and sales on
            the trend line. More specifically, we get the following 12 equations and predictions for sales
            for the year 2018 in thousands of USD:
            sales_january = 1.279*(year+0/12) - 2557.778 - 2.401

            = 1.279*(2018 + 0/12) - 2557.778 - 2.401 = 20.843

            sales_february = 1.279*(year+1/12) - 2557.778 - 1.358
            = 1.279*(2018+1/12) - 2557.778 - 1.358 = 21.993



                                                    [ 163 ]
   170   171   172   173   174   175   176   177   178   179   180