# Explain the croston method of R

I am using crost() function of R for analyzing and forecasting intermittent demand/slow moving items time series. I am having difficulty in understanding the output. Could anyone help in understanding the model in layman's terms.

Below is the code and output of the model:

v <- c(1910,874,1920,350,160,685,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,0,16,826,0,66,3798,800,1274,638,192,160,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,276,0,0,1072,80,1776,240,80,528,3081,566,1483,112,272,120,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,0,808,0,0,608,0,1480,184)
t <- ts(v, f=52)
x<-crost(t,h=52)
x


I have read the document of the Package ‘tsintermittent’, but still did not get what are weights, frc.in, frc.out. I would like to discuss this on thread as I am totally new to this method.

• Have you looked at the help page ?crost, specifically the Value section? Are you familiar with Croston's forecasting method? – Stephan Kolassa Dec 9 '14 at 17:22
• Hi Stephan, I have added the example which is intermittent. Yes, I have looked the help page. But still did not get, like if it is forecasting, how to get the non demand/demand periods and their forecasts, frc.in/frc.out etc. Would you please help in understanding. Please bear with me. – Arushi Dec 9 '14 at 19:30

x$frc.in is the in-sample demand rate. This is the in-sample estimate of average demand - as above, this is the ratio of the current value of smoothed nonzero demands, divided by the current value of smoothed inter-demand interval lengths. If you look closely, you see that this does not change during periods with zero demand... because Croston's method only updates (smoothes) its estimates for the inter-demand interval and for the nonzero demand when there is nonzero demand. x$frc.out is the out-of-sample demand rate, i.e., the forecast for average demand. As you see, it is constant, because Croston's method does not provide for out-of-sample dynamics like trend or seasonality.
x$weights are the optimized smoothing weights for smoothing the inter-demand interval and nonzero demand component. Originally, Croston used only a single (pre-set) weight for smoothing; Kourentzes apparently optimizes both weights separately. (I am not familiar with the reference given on the help page - it may be useful for you to read it, though.) Here is your time series, with the in-sample fit in red and the forecast in green: bar <- crost(t) plot(t,xlim=c(1,4.1)) lines(ts(bar$frc.in,frequency=52),col="red")
lines(ts(bar$frc.out,frequency=52,start=c(3,49)),col="green")  Now, looking at your data v, Croston's method is quite obviously inappropriate. Although you do have many zeros, your time series is not intermittent in any meaningful sense. Instead, it is obviously seasonal, with periods of nonzero demand alternating with periods of zero demand in a yearly pattern. I'd much more recommend using a method that explicitly models this seasonality, like stlf() in the forecast package. Its forecasts will go negative, so you need to truncate them at zero, that is, set all negative point forecasts to 0. pmax() is helpful here. Of course, prediction intervals from stlf() don't make much sense, since their calculation does not respect nonnegativity constraints, but I assume that you are mostly interested in point forecasts, anyway. For instance: foo <- stlf(t) foo$mean <- pmax(foo\$mean,0)    # truncate at zero

• Thanks a lot for quick response. How can I truncate the demand to zero? Secondly what is in sample estimate? Is it the demand during the periods when demand is non zero? I am really sorry for asking silly questions...stlf() is working fine, thanks for an alternative solution. – Arushi Dec 10 '14 at 10:56