Free Statistics

of Irreproducible Research!

Author's title

Author*Unverified author*
R Software ModulePatrick.Wessarwasp_demand_forecasting_croston.wasp
Title produced by softwareCroston Forecasting
Date of computationThu, 13 May 2010 13:26:49 +0000
Cite this page as followsStatistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?v=date/2010/May/13/t1273757245y3fn0docysrh2so.htm/, Retrieved Mon, 06 May 2024 04:05:25 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75935, Retrieved Mon, 06 May 2024 04:05:25 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywordsFM50,steven,coomans,thesis,croston,per2maand
Estimated Impact103
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-       [Croston Forecasting] [FM50,steven,cooma...] [2010-05-13 13:26:49] [d41d8cd98f00b204e9800998ecf8427e] [Current]
Feedback Forum

Post a new message
Dataseries X:
1201.42
1157.2125
1722.05
1918.2475
1930.4575
1264.1775
1456.3725
2168.985
1983.765
1672.695
1938.575
1307.6425
1523.3425
1928.39
2208.435
2290.175
2578.245
1152.84
1398.7575
1393.9175
1972.2525
2410.4775
2363.27
1341.6075
1437.0425




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time3 seconds
R Serverwessa.org @ wessa.org

\begin{tabular}{lllllllll}
\hline
Summary of computational transaction \tabularnewline
Raw Input & view raw input (R code)  \tabularnewline
Raw Output & view raw output of R engine  \tabularnewline
Computing time & 3 seconds \tabularnewline
R Server & wessa.org @ wessa.org \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75935&T=0

[TABLE]
[ROW][C]Summary of computational transaction[/C][/ROW]
[ROW][C]Raw Input[/C][C]view raw input (R code) [/C][/ROW]
[ROW][C]Raw Output[/C][C]view raw output of R engine [/C][/ROW]
[ROW][C]Computing time[/C][C]3 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]wessa.org @ wessa.org[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75935&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75935&T=0

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time3 seconds
R Serverwessa.org @ wessa.org







Demand Forecast
PointForecast95% LB80% LB80% UB95% UB
261744.43679493326856.0342514133831163.541595091672325.331994774842632.83933845313
271744.43679493326851.6032885470391160.644344201852328.229245664672637.27030131948
281744.43679493326847.1942073800161157.761400986172331.112188880352641.6793824865
291744.43679493326842.8066868997241154.892555545782333.981034320742646.06690296679
301744.43679493326838.4404138665961152.037603064332336.835986802182650.43317599992
311744.43679493326834.0950825531131149.196343637362339.677246229162654.7785073134
321744.43679493326829.7703944939831146.368582108892342.505007757632659.10319537253
331744.43679493326825.4660582469011143.554127915042345.319461951472663.40753161961
341744.43679493326821.1817891633511140.752794934162348.120794932362667.69180070316
351744.43679493326816.9173091689331137.964401343162350.909188523362671.95628069758

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
26 & 1744.43679493326 & 856.034251413383 & 1163.54159509167 & 2325.33199477484 & 2632.83933845313 \tabularnewline
27 & 1744.43679493326 & 851.603288547039 & 1160.64434420185 & 2328.22924566467 & 2637.27030131948 \tabularnewline
28 & 1744.43679493326 & 847.194207380016 & 1157.76140098617 & 2331.11218888035 & 2641.6793824865 \tabularnewline
29 & 1744.43679493326 & 842.806686899724 & 1154.89255554578 & 2333.98103432074 & 2646.06690296679 \tabularnewline
30 & 1744.43679493326 & 838.440413866596 & 1152.03760306433 & 2336.83598680218 & 2650.43317599992 \tabularnewline
31 & 1744.43679493326 & 834.095082553113 & 1149.19634363736 & 2339.67724622916 & 2654.7785073134 \tabularnewline
32 & 1744.43679493326 & 829.770394493983 & 1146.36858210889 & 2342.50500775763 & 2659.10319537253 \tabularnewline
33 & 1744.43679493326 & 825.466058246901 & 1143.55412791504 & 2345.31946195147 & 2663.40753161961 \tabularnewline
34 & 1744.43679493326 & 821.181789163351 & 1140.75279493416 & 2348.12079493236 & 2667.69180070316 \tabularnewline
35 & 1744.43679493326 & 816.917309168933 & 1137.96440134316 & 2350.90918852336 & 2671.95628069758 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75935&T=1

[TABLE]
[ROW][C]Demand Forecast[/C][/ROW]
[ROW][C]Point[/C][C]Forecast[/C][C]95% LB[/C][C]80% LB[/C][C]80% UB[/C][C]95% UB[/C][/ROW]
[ROW][C]26[/C][C]1744.43679493326[/C][C]856.034251413383[/C][C]1163.54159509167[/C][C]2325.33199477484[/C][C]2632.83933845313[/C][/ROW]
[ROW][C]27[/C][C]1744.43679493326[/C][C]851.603288547039[/C][C]1160.64434420185[/C][C]2328.22924566467[/C][C]2637.27030131948[/C][/ROW]
[ROW][C]28[/C][C]1744.43679493326[/C][C]847.194207380016[/C][C]1157.76140098617[/C][C]2331.11218888035[/C][C]2641.6793824865[/C][/ROW]
[ROW][C]29[/C][C]1744.43679493326[/C][C]842.806686899724[/C][C]1154.89255554578[/C][C]2333.98103432074[/C][C]2646.06690296679[/C][/ROW]
[ROW][C]30[/C][C]1744.43679493326[/C][C]838.440413866596[/C][C]1152.03760306433[/C][C]2336.83598680218[/C][C]2650.43317599992[/C][/ROW]
[ROW][C]31[/C][C]1744.43679493326[/C][C]834.095082553113[/C][C]1149.19634363736[/C][C]2339.67724622916[/C][C]2654.7785073134[/C][/ROW]
[ROW][C]32[/C][C]1744.43679493326[/C][C]829.770394493983[/C][C]1146.36858210889[/C][C]2342.50500775763[/C][C]2659.10319537253[/C][/ROW]
[ROW][C]33[/C][C]1744.43679493326[/C][C]825.466058246901[/C][C]1143.55412791504[/C][C]2345.31946195147[/C][C]2663.40753161961[/C][/ROW]
[ROW][C]34[/C][C]1744.43679493326[/C][C]821.181789163351[/C][C]1140.75279493416[/C][C]2348.12079493236[/C][C]2667.69180070316[/C][/ROW]
[ROW][C]35[/C][C]1744.43679493326[/C][C]816.917309168933[/C][C]1137.96440134316[/C][C]2350.90918852336[/C][C]2671.95628069758[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75935&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75935&T=1

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

Demand Forecast
PointForecast95% LB80% LB80% UB95% UB
261744.43679493326856.0342514133831163.541595091672325.331994774842632.83933845313
271744.43679493326851.6032885470391160.644344201852328.229245664672637.27030131948
281744.43679493326847.1942073800161157.761400986172331.112188880352641.6793824865
291744.43679493326842.8066868997241154.892555545782333.981034320742646.06690296679
301744.43679493326838.4404138665961152.037603064332336.835986802182650.43317599992
311744.43679493326834.0950825531131149.196343637362339.677246229162654.7785073134
321744.43679493326829.7703944939831146.368582108892342.505007757632659.10319537253
331744.43679493326825.4660582469011143.554127915042345.319461951472663.40753161961
341744.43679493326821.1817891633511140.752794934162348.120794932362667.69180070316
351744.43679493326816.9173091689331137.964401343162350.909188523362671.95628069758







Actuals and Interpolation
TimeActualForecast
11201.42NA
21157.21251201.42
31722.051196.99925
41918.24751249.504325
51930.45751316.3786425
61264.17751377.78652825
71456.37251366.425625425
82168.9851375.4203128825
91983.7651454.77678159425
101672.6951507.67560343483
111938.5751524.17754309134
121307.64251565.61728878221
131523.34251539.81980990399
141928.391538.17207891359
152208.4351577.19387102223
162290.1751640.31798392001
172578.2451705.30368552801
181152.841792.59781697521
191398.75751728.62203527769
201393.91751695.63558174992
211972.25251665.46377357493
222410.47751696.14264621743
232363.271767.57613159569
241341.60751827.14551843612
251437.04251778.59171659251

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 1201.42 & NA \tabularnewline
2 & 1157.2125 & 1201.42 \tabularnewline
3 & 1722.05 & 1196.99925 \tabularnewline
4 & 1918.2475 & 1249.504325 \tabularnewline
5 & 1930.4575 & 1316.3786425 \tabularnewline
6 & 1264.1775 & 1377.78652825 \tabularnewline
7 & 1456.3725 & 1366.425625425 \tabularnewline
8 & 2168.985 & 1375.4203128825 \tabularnewline
9 & 1983.765 & 1454.77678159425 \tabularnewline
10 & 1672.695 & 1507.67560343483 \tabularnewline
11 & 1938.575 & 1524.17754309134 \tabularnewline
12 & 1307.6425 & 1565.61728878221 \tabularnewline
13 & 1523.3425 & 1539.81980990399 \tabularnewline
14 & 1928.39 & 1538.17207891359 \tabularnewline
15 & 2208.435 & 1577.19387102223 \tabularnewline
16 & 2290.175 & 1640.31798392001 \tabularnewline
17 & 2578.245 & 1705.30368552801 \tabularnewline
18 & 1152.84 & 1792.59781697521 \tabularnewline
19 & 1398.7575 & 1728.62203527769 \tabularnewline
20 & 1393.9175 & 1695.63558174992 \tabularnewline
21 & 1972.2525 & 1665.46377357493 \tabularnewline
22 & 2410.4775 & 1696.14264621743 \tabularnewline
23 & 2363.27 & 1767.57613159569 \tabularnewline
24 & 1341.6075 & 1827.14551843612 \tabularnewline
25 & 1437.0425 & 1778.59171659251 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75935&T=2

[TABLE]
[ROW][C]Actuals and Interpolation[/C][/ROW]
[ROW][C]Time[/C][C]Actual[/C][C]Forecast[/C][/ROW]
[ROW][C]1[/C][C]1201.42[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]1157.2125[/C][C]1201.42[/C][/ROW]
[ROW][C]3[/C][C]1722.05[/C][C]1196.99925[/C][/ROW]
[ROW][C]4[/C][C]1918.2475[/C][C]1249.504325[/C][/ROW]
[ROW][C]5[/C][C]1930.4575[/C][C]1316.3786425[/C][/ROW]
[ROW][C]6[/C][C]1264.1775[/C][C]1377.78652825[/C][/ROW]
[ROW][C]7[/C][C]1456.3725[/C][C]1366.425625425[/C][/ROW]
[ROW][C]8[/C][C]2168.985[/C][C]1375.4203128825[/C][/ROW]
[ROW][C]9[/C][C]1983.765[/C][C]1454.77678159425[/C][/ROW]
[ROW][C]10[/C][C]1672.695[/C][C]1507.67560343483[/C][/ROW]
[ROW][C]11[/C][C]1938.575[/C][C]1524.17754309134[/C][/ROW]
[ROW][C]12[/C][C]1307.6425[/C][C]1565.61728878221[/C][/ROW]
[ROW][C]13[/C][C]1523.3425[/C][C]1539.81980990399[/C][/ROW]
[ROW][C]14[/C][C]1928.39[/C][C]1538.17207891359[/C][/ROW]
[ROW][C]15[/C][C]2208.435[/C][C]1577.19387102223[/C][/ROW]
[ROW][C]16[/C][C]2290.175[/C][C]1640.31798392001[/C][/ROW]
[ROW][C]17[/C][C]2578.245[/C][C]1705.30368552801[/C][/ROW]
[ROW][C]18[/C][C]1152.84[/C][C]1792.59781697521[/C][/ROW]
[ROW][C]19[/C][C]1398.7575[/C][C]1728.62203527769[/C][/ROW]
[ROW][C]20[/C][C]1393.9175[/C][C]1695.63558174992[/C][/ROW]
[ROW][C]21[/C][C]1972.2525[/C][C]1665.46377357493[/C][/ROW]
[ROW][C]22[/C][C]2410.4775[/C][C]1696.14264621743[/C][/ROW]
[ROW][C]23[/C][C]2363.27[/C][C]1767.57613159569[/C][/ROW]
[ROW][C]24[/C][C]1341.6075[/C][C]1827.14551843612[/C][/ROW]
[ROW][C]25[/C][C]1437.0425[/C][C]1778.59171659251[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75935&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75935&T=2

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

Actuals and Interpolation
TimeActualForecast
11201.42NA
21157.21251201.42
31722.051196.99925
41918.24751249.504325
51930.45751316.3786425
61264.17751377.78652825
71456.37251366.425625425
82168.9851375.4203128825
91983.7651454.77678159425
101672.6951507.67560343483
111938.5751524.17754309134
121307.64251565.61728878221
131523.34251539.81980990399
141928.391538.17207891359
152208.4351577.19387102223
162290.1751640.31798392001
172578.2451705.30368552801
181152.841792.59781697521
191398.75751728.62203527769
201393.91751695.63558174992
211972.25251665.46377357493
222410.47751696.14264621743
232363.271767.57613159569
241341.60751827.14551843612
251437.04251778.59171659251







\begin{tabular}{lllllllll}
\hline
What is next? \tabularnewline
Simulate Time Series \tabularnewline
Generate Forecasts \tabularnewline
Forecast Analysis \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75935&T=3

[TABLE]
[ROW][C]What is next?[/C][/ROW]
[ROW][C]Simulate Time Series[/C][/ROW]
[ROW][C]Generate Forecasts[/C][/ROW]
[ROW][C]Forecast Analysis[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75935&T=3

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75935&T=3

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

What is next?
Simulate Time Series
Generate Forecasts
Forecast Analysis



Parameters (Session):
par1 = Input box ; par2 = ARIMA ; par3 = NA ; par4 = NA ; par5 = ZZZ ; par6 = 12 ; par7 = dum ; par8 = dumresult ; par9 = 3 ; par10 = 0.1 ;
Parameters (R input):
par1 = Input box ; par2 = Croston ; par3 = NA ; par4 = NA ; par5 = ZZZ ; par6 = 12 ; par7 = dum ; par8 = dumresult ; par9 = 3 ; par10 = 0.1 ;
R code (references can be found in the software module):
if(par3!='NA') par3 <- as.numeric(par3) else par3 <- NA
if(par4!='NA') par4 <- as.numeric(par4) else par4 <- NA
par6 <- as.numeric(par6) #Seasonal Period
par9 <- as.numeric(par9) #Forecast Horizon
par10 <- as.numeric(par10) #Alpha
library(forecast)
if (par1 == 'CSV') {
xarr <- read.csv(file=paste('tmp/',par7,'.csv',sep=''),header=T)
numseries <- length(xarr[1,])-1
n <- length(xarr[,1])
nmh <- n - par9
nmhp1 <- nmh + 1
rarr <- array(NA,dim=c(n,numseries))
farr <- array(NA,dim=c(n,numseries))
parr <- array(NA,dim=c(numseries,8))
colnames(parr) = list('ME','RMSE','MAE','MPE','MAPE','MASE','ACF1','TheilU')
for(i in 1:numseries) {
sindex <- i+1
x <- xarr[,sindex]
if(par2=='Croston') {
if (i==1) m <- croston(x,alpha=par10)
if (i==1) mydemand <- m$model$demand[]
fit <- croston(x[1:nmh],h=par9,alpha=par10)
}
if(par2=='ARIMA') {
m <- auto.arima(ts(x,freq=par6),d=par3,D=par4)
mydemand <- forecast(m)
fit <- auto.arima(ts(x[1:nmh],freq=par6),d=par3,D=par4)
}
if(par2=='ETS') {
m <- ets(ts(x,freq=par6),model=par5)
mydemand <- forecast(m)
fit <- ets(ts(x[1:nmh],freq=par6),model=par5)
}
try(rarr[,i] <- mydemand$resid,silent=T)
try(farr[,i] <- mydemand$mean,silent=T)
if (par2!='Croston') parr[i,] <- accuracy(forecast(fit,par9),x[nmhp1:n])
if (par2=='Croston') parr[i,] <- accuracy(fit,x[nmhp1:n])
}
write.csv(farr,file=paste('tmp/',par8,'_f.csv',sep=''))
write.csv(rarr,file=paste('tmp/',par8,'_r.csv',sep=''))
write.csv(parr,file=paste('tmp/',par8,'_p.csv',sep=''))
}
if (par1 == 'Input box') {
numseries <- 1
n <- length(x)
if(par2=='Croston') {
m <- croston(x)
mydemand <- m$model$demand[]
}
if(par2=='ARIMA') {
m <- auto.arima(ts(x,freq=par6),d=par3,D=par4)
mydemand <- forecast(m)
}
if(par2=='ETS') {
m <- ets(ts(x,freq=par6),model=par5)
mydemand <- forecast(m)
}
summary(m)
}
bitmap(file='test1.png')
op <- par(mfrow=c(2,1))
if (par2=='Croston') plot(m)
if ((par2=='ARIMA') | par2=='ETS') plot(forecast(m))
plot(mydemand$resid,type='l',main='Residuals', ylab='residual value', xlab='time')
par(op)
dev.off()
bitmap(file='pic2.png')
op <- par(mfrow=c(2,2))
acf(mydemand$resid, lag.max=n/3, main='Residual ACF', ylab='autocorrelation', xlab='time lag')
pacf(mydemand$resid,lag.max=n/3, main='Residual PACF', ylab='partial autocorrelation', xlab='time lag')
cpgram(mydemand$resid, main='Cumulative Periodogram of Residuals')
qqnorm(mydemand$resid); qqline(mydemand$resid, col=2)
par(op)
dev.off()
load(file='createtable')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Demand Forecast',6,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Point',header=TRUE)
a<-table.element(a,'Forecast',header=TRUE)
a<-table.element(a,'95% LB',header=TRUE)
a<-table.element(a,'80% LB',header=TRUE)
a<-table.element(a,'80% UB',header=TRUE)
a<-table.element(a,'95% UB',header=TRUE)
a<-table.row.end(a)
for (i in 1:length(mydemand$mean)) {
a<-table.row.start(a)
a<-table.element(a,i+n,header=TRUE)
a<-table.element(a,as.numeric(mydemand$mean[i]))
a<-table.element(a,as.numeric(mydemand$lower[i,2]))
a<-table.element(a,as.numeric(mydemand$lower[i,1]))
a<-table.element(a,as.numeric(mydemand$upper[i,1]))
a<-table.element(a,as.numeric(mydemand$upper[i,2]))
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable.tab')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Actuals and Interpolation',3,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,'Time',header=TRUE)
a<-table.element(a,'Actual',header=TRUE)
a<-table.element(a,'Forecast',header=TRUE)
a<-table.row.end(a)
for (i in 1:n) {
a<-table.row.start(a)
a<-table.element(a,i,header=TRUE)
a<-table.element(a,x[i])
a<-table.element(a,x[i] - as.numeric(m$resid[i]))
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable1.tab')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'What is next?',1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,hyperlink(paste('https://automated.biganalytics.eu/Patrick.Wessa/rwasp_demand_forecasting_simulate.wasp',sep=''),'Simulate Time Series','',target=''))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,hyperlink(paste('https://automated.biganalytics.eu/Patrick.Wessa/rwasp_demand_forecasting_croston.wasp',sep=''),'Generate Forecasts','',target=''))
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,hyperlink(paste('https://automated.biganalytics.eu/Patrick.Wessa/rwasp_demand_forecasting_analysis.wasp',sep=''),'Forecast Analysis','',target=''))
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file='mytable0.tab')
-SERVER-wessa.org