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:17:19 +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/t1273756671fz9mslku194on9f.htm/, Retrieved Sun, 05 May 2024 23:27:43 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75927, Retrieved Sun, 05 May 2024 23:27:43 +0000
QR Codes:

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

Post a new message
Dataseries X:
719,625
689,5125
640,5
541,3875
521,3875
613,325
683
728,6375
452,5375
380,425
377,125
316,75
387,2625
409,75
497,875
616,4
715,5125
454,925
464,25
247,675
292,5125
416,525
481,6625
219,7625
402,625




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=75927&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=75927&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75927&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
26451.17329890796204.757061639711290.050381784133612.296216031789697.58953617621
27451.17329890796203.528045350909289.246771227297613.099826588625698.818552465012
28451.17329890796202.305098389632288.44712919042613.899468625501700.041499426289
29451.17329890796201.088131716611287.651397453854614.695200362068701.25846609931
30451.17329890796199.877058448578286.859519207682615.487078608239702.469539367343
31451.17329890796198.671793785884286.071439004395616.275158811526703.674804030037
32451.17329890796197.472254943201285.287102713577617.059495102344704.87434287272
33451.17329890796196.278361083171284.506457478520617.840140337401706.06823673275
34451.17329890796195.090033252827283.729451674653618.617146141268707.256564563094
35451.17329890796193.907194322666282.956034869705619.390562946216708.439403493255

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
26 & 451.17329890796 & 204.757061639711 & 290.050381784133 & 612.296216031789 & 697.58953617621 \tabularnewline
27 & 451.17329890796 & 203.528045350909 & 289.246771227297 & 613.099826588625 & 698.818552465012 \tabularnewline
28 & 451.17329890796 & 202.305098389632 & 288.44712919042 & 613.899468625501 & 700.041499426289 \tabularnewline
29 & 451.17329890796 & 201.088131716611 & 287.651397453854 & 614.695200362068 & 701.25846609931 \tabularnewline
30 & 451.17329890796 & 199.877058448578 & 286.859519207682 & 615.487078608239 & 702.469539367343 \tabularnewline
31 & 451.17329890796 & 198.671793785884 & 286.071439004395 & 616.275158811526 & 703.674804030037 \tabularnewline
32 & 451.17329890796 & 197.472254943201 & 285.287102713577 & 617.059495102344 & 704.87434287272 \tabularnewline
33 & 451.17329890796 & 196.278361083171 & 284.506457478520 & 617.840140337401 & 706.06823673275 \tabularnewline
34 & 451.17329890796 & 195.090033252827 & 283.729451674653 & 618.617146141268 & 707.256564563094 \tabularnewline
35 & 451.17329890796 & 193.907194322666 & 282.956034869705 & 619.390562946216 & 708.439403493255 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75927&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]451.17329890796[/C][C]204.757061639711[/C][C]290.050381784133[/C][C]612.296216031789[/C][C]697.58953617621[/C][/ROW]
[ROW][C]27[/C][C]451.17329890796[/C][C]203.528045350909[/C][C]289.246771227297[/C][C]613.099826588625[/C][C]698.818552465012[/C][/ROW]
[ROW][C]28[/C][C]451.17329890796[/C][C]202.305098389632[/C][C]288.44712919042[/C][C]613.899468625501[/C][C]700.041499426289[/C][/ROW]
[ROW][C]29[/C][C]451.17329890796[/C][C]201.088131716611[/C][C]287.651397453854[/C][C]614.695200362068[/C][C]701.25846609931[/C][/ROW]
[ROW][C]30[/C][C]451.17329890796[/C][C]199.877058448578[/C][C]286.859519207682[/C][C]615.487078608239[/C][C]702.469539367343[/C][/ROW]
[ROW][C]31[/C][C]451.17329890796[/C][C]198.671793785884[/C][C]286.071439004395[/C][C]616.275158811526[/C][C]703.674804030037[/C][/ROW]
[ROW][C]32[/C][C]451.17329890796[/C][C]197.472254943201[/C][C]285.287102713577[/C][C]617.059495102344[/C][C]704.87434287272[/C][/ROW]
[ROW][C]33[/C][C]451.17329890796[/C][C]196.278361083171[/C][C]284.506457478520[/C][C]617.840140337401[/C][C]706.06823673275[/C][/ROW]
[ROW][C]34[/C][C]451.17329890796[/C][C]195.090033252827[/C][C]283.729451674653[/C][C]618.617146141268[/C][C]707.256564563094[/C][/ROW]
[ROW][C]35[/C][C]451.17329890796[/C][C]193.907194322666[/C][C]282.956034869705[/C][C]619.390562946216[/C][C]708.439403493255[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75927&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75927&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
26451.17329890796204.757061639711290.050381784133612.296216031789697.58953617621
27451.17329890796203.528045350909289.246771227297613.099826588625698.818552465012
28451.17329890796202.305098389632288.44712919042613.899468625501700.041499426289
29451.17329890796201.088131716611287.651397453854614.695200362068701.25846609931
30451.17329890796199.877058448578286.859519207682615.487078608239702.469539367343
31451.17329890796198.671793785884286.071439004395616.275158811526703.674804030037
32451.17329890796197.472254943201285.287102713577617.059495102344704.87434287272
33451.17329890796196.278361083171284.506457478520617.840140337401706.06823673275
34451.17329890796195.090033252827283.729451674653618.617146141268707.256564563094
35451.17329890796193.907194322666282.956034869705619.390562946216708.439403493255







Actuals and Interpolation
TimeActualForecast
1719.625NA
2689.5125719.625
3640.5716.61375
4541.3875709.002375
5521.3875692.2408875
6613.325675.15554875
7683668.972493875
8728.6375670.3752444875
9452.5375676.20147003875
10380.425653.835073034875
11377.125626.494065731387
12316.75601.557159158249
13387.2625573.076443242424
14409.75554.495048918181
15497.875540.020544026363
16616.4535.805989623727
17715.5125543.865390661354
18454.925561.030101595219
19464.25550.419591435697
20247.675541.802632292127
21292.5125512.389869062915
22416.525490.402132156623
23481.6625483.014418940961
24219.7625482.879227046865
25402.625456.567554342178

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 719.625 & NA \tabularnewline
2 & 689.5125 & 719.625 \tabularnewline
3 & 640.5 & 716.61375 \tabularnewline
4 & 541.3875 & 709.002375 \tabularnewline
5 & 521.3875 & 692.2408875 \tabularnewline
6 & 613.325 & 675.15554875 \tabularnewline
7 & 683 & 668.972493875 \tabularnewline
8 & 728.6375 & 670.3752444875 \tabularnewline
9 & 452.5375 & 676.20147003875 \tabularnewline
10 & 380.425 & 653.835073034875 \tabularnewline
11 & 377.125 & 626.494065731387 \tabularnewline
12 & 316.75 & 601.557159158249 \tabularnewline
13 & 387.2625 & 573.076443242424 \tabularnewline
14 & 409.75 & 554.495048918181 \tabularnewline
15 & 497.875 & 540.020544026363 \tabularnewline
16 & 616.4 & 535.805989623727 \tabularnewline
17 & 715.5125 & 543.865390661354 \tabularnewline
18 & 454.925 & 561.030101595219 \tabularnewline
19 & 464.25 & 550.419591435697 \tabularnewline
20 & 247.675 & 541.802632292127 \tabularnewline
21 & 292.5125 & 512.389869062915 \tabularnewline
22 & 416.525 & 490.402132156623 \tabularnewline
23 & 481.6625 & 483.014418940961 \tabularnewline
24 & 219.7625 & 482.879227046865 \tabularnewline
25 & 402.625 & 456.567554342178 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75927&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]719.625[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]689.5125[/C][C]719.625[/C][/ROW]
[ROW][C]3[/C][C]640.5[/C][C]716.61375[/C][/ROW]
[ROW][C]4[/C][C]541.3875[/C][C]709.002375[/C][/ROW]
[ROW][C]5[/C][C]521.3875[/C][C]692.2408875[/C][/ROW]
[ROW][C]6[/C][C]613.325[/C][C]675.15554875[/C][/ROW]
[ROW][C]7[/C][C]683[/C][C]668.972493875[/C][/ROW]
[ROW][C]8[/C][C]728.6375[/C][C]670.3752444875[/C][/ROW]
[ROW][C]9[/C][C]452.5375[/C][C]676.20147003875[/C][/ROW]
[ROW][C]10[/C][C]380.425[/C][C]653.835073034875[/C][/ROW]
[ROW][C]11[/C][C]377.125[/C][C]626.494065731387[/C][/ROW]
[ROW][C]12[/C][C]316.75[/C][C]601.557159158249[/C][/ROW]
[ROW][C]13[/C][C]387.2625[/C][C]573.076443242424[/C][/ROW]
[ROW][C]14[/C][C]409.75[/C][C]554.495048918181[/C][/ROW]
[ROW][C]15[/C][C]497.875[/C][C]540.020544026363[/C][/ROW]
[ROW][C]16[/C][C]616.4[/C][C]535.805989623727[/C][/ROW]
[ROW][C]17[/C][C]715.5125[/C][C]543.865390661354[/C][/ROW]
[ROW][C]18[/C][C]454.925[/C][C]561.030101595219[/C][/ROW]
[ROW][C]19[/C][C]464.25[/C][C]550.419591435697[/C][/ROW]
[ROW][C]20[/C][C]247.675[/C][C]541.802632292127[/C][/ROW]
[ROW][C]21[/C][C]292.5125[/C][C]512.389869062915[/C][/ROW]
[ROW][C]22[/C][C]416.525[/C][C]490.402132156623[/C][/ROW]
[ROW][C]23[/C][C]481.6625[/C][C]483.014418940961[/C][/ROW]
[ROW][C]24[/C][C]219.7625[/C][C]482.879227046865[/C][/ROW]
[ROW][C]25[/C][C]402.625[/C][C]456.567554342178[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75927&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75927&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
1719.625NA
2689.5125719.625
3640.5716.61375
4541.3875709.002375
5521.3875692.2408875
6613.325675.15554875
7683668.972493875
8728.6375670.3752444875
9452.5375676.20147003875
10380.425653.835073034875
11377.125626.494065731387
12316.75601.557159158249
13387.2625573.076443242424
14409.75554.495048918181
15497.875540.020544026363
16616.4535.805989623727
17715.5125543.865390661354
18454.925561.030101595219
19464.25550.419591435697
20247.675541.802632292127
21292.5125512.389869062915
22416.525490.402132156623
23481.6625483.014418940961
24219.7625482.879227046865
25402.625456.567554342178







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

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