# Making Sense out of the Nonsense: PAL: 77. Time Series – Croston’s Method

The first thing that came to my mind when reading about Croston’s Method was “The Incoherence of the Incoherence” a book written back in the further day.    In a similar way, the Croston’s Method deals with uncertainties, data that can appear random, it’s at its most reliable with intermittent demand over a long period.  Now in this part of the data playground there aren’t many other rides to choose from.  So before I review this video by Philip Mugglestone of the SAP HANA Academy on Croston’s  Method it’s worth mentioning that I did some of the research that Philip recommends at the start of the video.

An executive summary follows.  The jury is still out regarding Croston’s efficacy but as Winston Churchill said about systems of government.  “Democracy is the worst form of government, except for all the others.”   The Croston’s method is the only tool you really have when dealing with low demand over a long time period.

Philip starts by highlighting that Croston’s Method is new in SPS09 and refers to the reference guide for technical information, formulae and explanations of how it works.

Philip discusses how the Croston’s Method deals with demand which may not be linear.  When demand is intermittent this method is better than exponential smoothing methods which are more suited to more consistent demand which appears linear on a graph.  SAP are right up there in Google searches as they have been using it in power supply chain and demand forecasting solutions for some time.  However, it’s now available for you to use directly in HANA with SPS09.

Philip recommends the links below for further reading.  I have selected the key phrases.

 https://help.sap.com/saphelp_scm70/helpdata/en/ac/216b89337b11d398290000e8a49608/content.htm The Croston method consists of two steps. First, separate exponential smoothing estimates are made of the average size of a demand. Second, the average interval between demands is calculated. This is then used in a form of the constant model to predict the future demand.

In HANA you start with SQL script.  You can see that the structure of the code is very straightforward.

The same as is used for other algorithms.  It’s extremely similar to working with the other time series from the PAL.   You’ve got four tables that are always involved and a statistics table should you need it with the measures provided when using exponential smoothing.  A reminder that inSPS09 so you need to specify the column in the schema and the stored procedure to be created.  The call procedure is new and you will notice that in this example it includes the name CROSTON.

This definition along with how it can be used can be found in the manual.

You will notice from the manual quite a few parameters when calling this method.  Again for the data view it’s the same as for the other time series examples.  For Croston’s Method, the table structure’s the same but the parameters are slightly different.  Crostons allows you to specify a number of periods that you want to predict.  There are two methods – sporadic and constant.  Again like in exponential smoothing there are nine parameters or measures you can use.

Here you can see the your smoothed data with three additional time periods for forecasting. In the statistics table you’ve got name value pairs for those nine optional focus accuracy measures then you have sales amount with the predicted amount together.

The tutorial ends with a recap of how to use this data to make a chart.  The data shown below is not over a long period or intermittent enough but you still get a curve whereas if the data had been smoothed it would have been linear.

Unpredictability can be exciting.  SPS09 has benefited from SAP’s previous experience of Croston’s Method.  They have allowed themselves to be submitted to the unpredictable vicissitudes of the data  forecasting world.  In this field of data analysis, it’s easy to be wrong.  Is this then a thankless task with no winners?  “He who dares wins” as Del Boy used to say quoting the SAS motto.  Sometimes in life you have to take a leap of faith.  The anticipation of reward encourages humans to take gambles that other life forms wouldn’t..  When a big software company makes the same decisons, it’s time to get excited. Something, unexpectedly good, is ahead.