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:28:41 +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/t1273757362c7iw78mxqisxs5o.htm/, Retrieved Mon, 06 May 2024 03:26:21 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75936, Retrieved Mon, 06 May 2024 03:26:21 +0000
QR Codes:

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

Post a new message
Dataseries X:
724
762,275
721,125
653,275
663,7125
735,5125
628,1375
792,55
636,5
800,825
728,05
618,2625
450,625
767,525
675,65
583,25
690,7875
208,0625
142,5
205,925
462,5625
251,4375
195,725
191,625
137,25




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time2 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 & 2 seconds \tabularnewline
R Server & wessa.org @ wessa.org \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75936&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]2 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]wessa.org @ wessa.org[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75936&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75936&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 time2 seconds
R Serverwessa.org @ wessa.org







Demand Forecast
PointForecast95% LB80% LB80% UB95% UB
26417.95176940406171.6250244704416191.500882724222644.4026560839764.278514337681
27417.95176940406169.8976983190075190.371444861569645.532093946554766.005840489115
28417.95176940406168.1789023296656189.247584572110646.655954236012767.724636478457
29417.95176940406166.4685113617955188.129220030794647.774318777329769.435027446327
30417.95176940406164.7664033049416187.016271393883648.887267414239771.137135503181
31417.95176940406163.0724589770764185.908660732440649.994878075682772.831079831046
32417.95176940406161.3865620272121184.806311968643651.09722683948774.51697678091
33417.95176940406159.7085988421389183.709150814806652.194387993317776.194939965984
34417.95176940406158.0384584570754182.617104714959653.286434093164777.865080351047
35417.95176940406156.3760324700339181.530102788852654.37343601927779.527506338089

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
26 & 417.951769404061 & 71.6250244704416 & 191.500882724222 & 644.4026560839 & 764.278514337681 \tabularnewline
27 & 417.951769404061 & 69.8976983190075 & 190.371444861569 & 645.532093946554 & 766.005840489115 \tabularnewline
28 & 417.951769404061 & 68.1789023296656 & 189.247584572110 & 646.655954236012 & 767.724636478457 \tabularnewline
29 & 417.951769404061 & 66.4685113617955 & 188.129220030794 & 647.774318777329 & 769.435027446327 \tabularnewline
30 & 417.951769404061 & 64.7664033049416 & 187.016271393883 & 648.887267414239 & 771.137135503181 \tabularnewline
31 & 417.951769404061 & 63.0724589770764 & 185.908660732440 & 649.994878075682 & 772.831079831046 \tabularnewline
32 & 417.951769404061 & 61.3865620272121 & 184.806311968643 & 651.09722683948 & 774.51697678091 \tabularnewline
33 & 417.951769404061 & 59.7085988421389 & 183.709150814806 & 652.194387993317 & 776.194939965984 \tabularnewline
34 & 417.951769404061 & 58.0384584570754 & 182.617104714959 & 653.286434093164 & 777.865080351047 \tabularnewline
35 & 417.951769404061 & 56.3760324700339 & 181.530102788852 & 654.37343601927 & 779.527506338089 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75936&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]417.951769404061[/C][C]71.6250244704416[/C][C]191.500882724222[/C][C]644.4026560839[/C][C]764.278514337681[/C][/ROW]
[ROW][C]27[/C][C]417.951769404061[/C][C]69.8976983190075[/C][C]190.371444861569[/C][C]645.532093946554[/C][C]766.005840489115[/C][/ROW]
[ROW][C]28[/C][C]417.951769404061[/C][C]68.1789023296656[/C][C]189.247584572110[/C][C]646.655954236012[/C][C]767.724636478457[/C][/ROW]
[ROW][C]29[/C][C]417.951769404061[/C][C]66.4685113617955[/C][C]188.129220030794[/C][C]647.774318777329[/C][C]769.435027446327[/C][/ROW]
[ROW][C]30[/C][C]417.951769404061[/C][C]64.7664033049416[/C][C]187.016271393883[/C][C]648.887267414239[/C][C]771.137135503181[/C][/ROW]
[ROW][C]31[/C][C]417.951769404061[/C][C]63.0724589770764[/C][C]185.908660732440[/C][C]649.994878075682[/C][C]772.831079831046[/C][/ROW]
[ROW][C]32[/C][C]417.951769404061[/C][C]61.3865620272121[/C][C]184.806311968643[/C][C]651.09722683948[/C][C]774.51697678091[/C][/ROW]
[ROW][C]33[/C][C]417.951769404061[/C][C]59.7085988421389[/C][C]183.709150814806[/C][C]652.194387993317[/C][C]776.194939965984[/C][/ROW]
[ROW][C]34[/C][C]417.951769404061[/C][C]58.0384584570754[/C][C]182.617104714959[/C][C]653.286434093164[/C][C]777.865080351047[/C][/ROW]
[ROW][C]35[/C][C]417.951769404061[/C][C]56.3760324700339[/C][C]181.530102788852[/C][C]654.37343601927[/C][C]779.527506338089[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75936&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75936&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
26417.95176940406171.6250244704416191.500882724222644.4026560839764.278514337681
27417.95176940406169.8976983190075190.371444861569645.532093946554766.005840489115
28417.95176940406168.1789023296656189.247584572110646.655954236012767.724636478457
29417.95176940406166.4685113617955188.129220030794647.774318777329769.435027446327
30417.95176940406164.7664033049416187.016271393883648.887267414239771.137135503181
31417.95176940406163.0724589770764185.908660732440649.994878075682772.831079831046
32417.95176940406161.3865620272121184.806311968643651.09722683948774.51697678091
33417.95176940406159.7085988421389183.709150814806652.194387993317776.194939965984
34417.95176940406158.0384584570754182.617104714959653.286434093164777.865080351047
35417.95176940406156.3760324700339181.530102788852654.37343601927779.527506338089







Actuals and Interpolation
TimeActualForecast
1724NA
2762.275724
3721.125727.8275
4653.275727.15725
5663.7125719.769025
6735.5125714.1633725
7628.1375716.29828525
8792.55707.482206725
9636.5715.9889860525
10800.825708.04008744725
11728.05717.318578702525
12618.2625718.391720832272
13450.625708.378798749045
14767.525682.60341887414
15675.65691.095576986727
16583.25689.551019288054
17690.7875678.920917359249
18208.0625680.107575623324
19142.5632.903068060991
20205.925583.862761254892
21462.5625546.068985129403
22251.4375537.718336616463
23195.725509.090252954817
24191.625477.753727659335
25137.25449.140854893401

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 724 & NA \tabularnewline
2 & 762.275 & 724 \tabularnewline
3 & 721.125 & 727.8275 \tabularnewline
4 & 653.275 & 727.15725 \tabularnewline
5 & 663.7125 & 719.769025 \tabularnewline
6 & 735.5125 & 714.1633725 \tabularnewline
7 & 628.1375 & 716.29828525 \tabularnewline
8 & 792.55 & 707.482206725 \tabularnewline
9 & 636.5 & 715.9889860525 \tabularnewline
10 & 800.825 & 708.04008744725 \tabularnewline
11 & 728.05 & 717.318578702525 \tabularnewline
12 & 618.2625 & 718.391720832272 \tabularnewline
13 & 450.625 & 708.378798749045 \tabularnewline
14 & 767.525 & 682.60341887414 \tabularnewline
15 & 675.65 & 691.095576986727 \tabularnewline
16 & 583.25 & 689.551019288054 \tabularnewline
17 & 690.7875 & 678.920917359249 \tabularnewline
18 & 208.0625 & 680.107575623324 \tabularnewline
19 & 142.5 & 632.903068060991 \tabularnewline
20 & 205.925 & 583.862761254892 \tabularnewline
21 & 462.5625 & 546.068985129403 \tabularnewline
22 & 251.4375 & 537.718336616463 \tabularnewline
23 & 195.725 & 509.090252954817 \tabularnewline
24 & 191.625 & 477.753727659335 \tabularnewline
25 & 137.25 & 449.140854893401 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75936&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]724[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]762.275[/C][C]724[/C][/ROW]
[ROW][C]3[/C][C]721.125[/C][C]727.8275[/C][/ROW]
[ROW][C]4[/C][C]653.275[/C][C]727.15725[/C][/ROW]
[ROW][C]5[/C][C]663.7125[/C][C]719.769025[/C][/ROW]
[ROW][C]6[/C][C]735.5125[/C][C]714.1633725[/C][/ROW]
[ROW][C]7[/C][C]628.1375[/C][C]716.29828525[/C][/ROW]
[ROW][C]8[/C][C]792.55[/C][C]707.482206725[/C][/ROW]
[ROW][C]9[/C][C]636.5[/C][C]715.9889860525[/C][/ROW]
[ROW][C]10[/C][C]800.825[/C][C]708.04008744725[/C][/ROW]
[ROW][C]11[/C][C]728.05[/C][C]717.318578702525[/C][/ROW]
[ROW][C]12[/C][C]618.2625[/C][C]718.391720832272[/C][/ROW]
[ROW][C]13[/C][C]450.625[/C][C]708.378798749045[/C][/ROW]
[ROW][C]14[/C][C]767.525[/C][C]682.60341887414[/C][/ROW]
[ROW][C]15[/C][C]675.65[/C][C]691.095576986727[/C][/ROW]
[ROW][C]16[/C][C]583.25[/C][C]689.551019288054[/C][/ROW]
[ROW][C]17[/C][C]690.7875[/C][C]678.920917359249[/C][/ROW]
[ROW][C]18[/C][C]208.0625[/C][C]680.107575623324[/C][/ROW]
[ROW][C]19[/C][C]142.5[/C][C]632.903068060991[/C][/ROW]
[ROW][C]20[/C][C]205.925[/C][C]583.862761254892[/C][/ROW]
[ROW][C]21[/C][C]462.5625[/C][C]546.068985129403[/C][/ROW]
[ROW][C]22[/C][C]251.4375[/C][C]537.718336616463[/C][/ROW]
[ROW][C]23[/C][C]195.725[/C][C]509.090252954817[/C][/ROW]
[ROW][C]24[/C][C]191.625[/C][C]477.753727659335[/C][/ROW]
[ROW][C]25[/C][C]137.25[/C][C]449.140854893401[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75936&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75936&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
1724NA
2762.275724
3721.125727.8275
4653.275727.15725
5663.7125719.769025
6735.5125714.1633725
7628.1375716.29828525
8792.55707.482206725
9636.5715.9889860525
10800.825708.04008744725
11728.05717.318578702525
12618.2625718.391720832272
13450.625708.378798749045
14767.525682.60341887414
15675.65691.095576986727
16583.25689.551019288054
17690.7875678.920917359249
18208.0625680.107575623324
19142.5632.903068060991
20205.925583.862761254892
21462.5625546.068985129403
22251.4375537.718336616463
23195.725509.090252954817
24191.625477.753727659335
25137.25449.140854893401







\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=75936&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=75936&T=3

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75936&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