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 12:52:45 +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/t1273755209dg77s3ds6q2y0me.htm/, Retrieved Mon, 06 May 2024 03:17:36 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75909, Retrieved Mon, 06 May 2024 03:17:36 +0000
QR Codes:

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

Post a new message
Dataseries X:
46
40,5
22,5
25
22,25
7
11
50,25
16,25
32,5
5,7525
7,75
14
3,5
1,25
3,0125
0,5
0
0,875
3,125
10
0
21
0
0,4125




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75909&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
2613.8322811470584-9.16879650593073-1.2073151454819228.871877439598736.8333588000475
2713.8322811470584-9.28351580936999-1.2823260661317128.946888360248536.9480781034868
2813.8322811470584-9.39766858734293-1.356966555689929.021528849806737.0622308814597
2913.8322811470584-9.51126315098685-1.4312420485170729.095804342633937.1758254451036
3013.8322811470584-9.6243076101925-1.5051578473857629.169720141502637.2888699043093
3113.8322811470584-9.73680988036091-1.5787191278985229.243281422015337.4013721744777
3213.8322811470584-9.84877768887134-1.6519309427170529.316493236833837.5133399829881
3313.8322811470584-9.9602185812752-1.7247982256122329.389360519729037.624780875392
3413.8322811470584-10.0711399272302-1.7973257953442229.46188808946137.7357022213470
3513.8322811470584-10.1815489261875-1.8695183593811729.53408065349837.8461112203043

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
26 & 13.8322811470584 & -9.16879650593073 & -1.20731514548192 & 28.8718774395987 & 36.8333588000475 \tabularnewline
27 & 13.8322811470584 & -9.28351580936999 & -1.28232606613171 & 28.9468883602485 & 36.9480781034868 \tabularnewline
28 & 13.8322811470584 & -9.39766858734293 & -1.3569665556899 & 29.0215288498067 & 37.0622308814597 \tabularnewline
29 & 13.8322811470584 & -9.51126315098685 & -1.43124204851707 & 29.0958043426339 & 37.1758254451036 \tabularnewline
30 & 13.8322811470584 & -9.6243076101925 & -1.50515784738576 & 29.1697201415026 & 37.2888699043093 \tabularnewline
31 & 13.8322811470584 & -9.73680988036091 & -1.57871912789852 & 29.2432814220153 & 37.4013721744777 \tabularnewline
32 & 13.8322811470584 & -9.84877768887134 & -1.65193094271705 & 29.3164932368338 & 37.5133399829881 \tabularnewline
33 & 13.8322811470584 & -9.9602185812752 & -1.72479822561223 & 29.3893605197290 & 37.624780875392 \tabularnewline
34 & 13.8322811470584 & -10.0711399272302 & -1.79732579534422 & 29.461888089461 & 37.7357022213470 \tabularnewline
35 & 13.8322811470584 & -10.1815489261875 & -1.86951835938117 & 29.534080653498 & 37.8461112203043 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75909&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]13.8322811470584[/C][C]-9.16879650593073[/C][C]-1.20731514548192[/C][C]28.8718774395987[/C][C]36.8333588000475[/C][/ROW]
[ROW][C]27[/C][C]13.8322811470584[/C][C]-9.28351580936999[/C][C]-1.28232606613171[/C][C]28.9468883602485[/C][C]36.9480781034868[/C][/ROW]
[ROW][C]28[/C][C]13.8322811470584[/C][C]-9.39766858734293[/C][C]-1.3569665556899[/C][C]29.0215288498067[/C][C]37.0622308814597[/C][/ROW]
[ROW][C]29[/C][C]13.8322811470584[/C][C]-9.51126315098685[/C][C]-1.43124204851707[/C][C]29.0958043426339[/C][C]37.1758254451036[/C][/ROW]
[ROW][C]30[/C][C]13.8322811470584[/C][C]-9.6243076101925[/C][C]-1.50515784738576[/C][C]29.1697201415026[/C][C]37.2888699043093[/C][/ROW]
[ROW][C]31[/C][C]13.8322811470584[/C][C]-9.73680988036091[/C][C]-1.57871912789852[/C][C]29.2432814220153[/C][C]37.4013721744777[/C][/ROW]
[ROW][C]32[/C][C]13.8322811470584[/C][C]-9.84877768887134[/C][C]-1.65193094271705[/C][C]29.3164932368338[/C][C]37.5133399829881[/C][/ROW]
[ROW][C]33[/C][C]13.8322811470584[/C][C]-9.9602185812752[/C][C]-1.72479822561223[/C][C]29.3893605197290[/C][C]37.624780875392[/C][/ROW]
[ROW][C]34[/C][C]13.8322811470584[/C][C]-10.0711399272302[/C][C]-1.79732579534422[/C][C]29.461888089461[/C][C]37.7357022213470[/C][/ROW]
[ROW][C]35[/C][C]13.8322811470584[/C][C]-10.1815489261875[/C][C]-1.86951835938117[/C][C]29.534080653498[/C][C]37.8461112203043[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75909&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75909&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
2613.8322811470584-9.16879650593073-1.2073151454819228.871877439598736.8333588000475
2713.8322811470584-9.28351580936999-1.2823260661317128.946888360248536.9480781034868
2813.8322811470584-9.39766858734293-1.356966555689929.021528849806737.0622308814597
2913.8322811470584-9.51126315098685-1.4312420485170729.095804342633937.1758254451036
3013.8322811470584-9.6243076101925-1.5051578473857629.169720141502637.2888699043093
3113.8322811470584-9.73680988036091-1.5787191278985229.243281422015337.4013721744777
3213.8322811470584-9.84877768887134-1.6519309427170529.316493236833837.5133399829881
3313.8322811470584-9.9602185812752-1.7247982256122329.389360519729037.624780875392
3413.8322811470584-10.0711399272302-1.7973257953442229.46188808946137.7357022213470
3513.8322811470584-10.1815489261875-1.8695183593811729.53408065349837.8461112203043







Actuals and Interpolation
TimeActualForecast
146NA
240.546
322.545.45
42543.155
522.2541.3395
6739.43055
71136.187495
850.2533.6687455
916.2535.32687095
1032.533.419183855
115.752533.3272654695
127.7530.56978892255
131428.287810030295
143.526.8590290272655
151.2524.5231261245390
163.012522.1958135120851
170.520.2774821608766
18018.2997339447889
190.87518.2997339447889
203.12515.0520550457364
211013.9578298121826
22013.5917030950519
232113.5917030950519
24013.0645135486197
250.412513.0645135486197

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 46 & NA \tabularnewline
2 & 40.5 & 46 \tabularnewline
3 & 22.5 & 45.45 \tabularnewline
4 & 25 & 43.155 \tabularnewline
5 & 22.25 & 41.3395 \tabularnewline
6 & 7 & 39.43055 \tabularnewline
7 & 11 & 36.187495 \tabularnewline
8 & 50.25 & 33.6687455 \tabularnewline
9 & 16.25 & 35.32687095 \tabularnewline
10 & 32.5 & 33.419183855 \tabularnewline
11 & 5.7525 & 33.3272654695 \tabularnewline
12 & 7.75 & 30.56978892255 \tabularnewline
13 & 14 & 28.287810030295 \tabularnewline
14 & 3.5 & 26.8590290272655 \tabularnewline
15 & 1.25 & 24.5231261245390 \tabularnewline
16 & 3.0125 & 22.1958135120851 \tabularnewline
17 & 0.5 & 20.2774821608766 \tabularnewline
18 & 0 & 18.2997339447889 \tabularnewline
19 & 0.875 & 18.2997339447889 \tabularnewline
20 & 3.125 & 15.0520550457364 \tabularnewline
21 & 10 & 13.9578298121826 \tabularnewline
22 & 0 & 13.5917030950519 \tabularnewline
23 & 21 & 13.5917030950519 \tabularnewline
24 & 0 & 13.0645135486197 \tabularnewline
25 & 0.4125 & 13.0645135486197 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75909&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]46[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]40.5[/C][C]46[/C][/ROW]
[ROW][C]3[/C][C]22.5[/C][C]45.45[/C][/ROW]
[ROW][C]4[/C][C]25[/C][C]43.155[/C][/ROW]
[ROW][C]5[/C][C]22.25[/C][C]41.3395[/C][/ROW]
[ROW][C]6[/C][C]7[/C][C]39.43055[/C][/ROW]
[ROW][C]7[/C][C]11[/C][C]36.187495[/C][/ROW]
[ROW][C]8[/C][C]50.25[/C][C]33.6687455[/C][/ROW]
[ROW][C]9[/C][C]16.25[/C][C]35.32687095[/C][/ROW]
[ROW][C]10[/C][C]32.5[/C][C]33.419183855[/C][/ROW]
[ROW][C]11[/C][C]5.7525[/C][C]33.3272654695[/C][/ROW]
[ROW][C]12[/C][C]7.75[/C][C]30.56978892255[/C][/ROW]
[ROW][C]13[/C][C]14[/C][C]28.287810030295[/C][/ROW]
[ROW][C]14[/C][C]3.5[/C][C]26.8590290272655[/C][/ROW]
[ROW][C]15[/C][C]1.25[/C][C]24.5231261245390[/C][/ROW]
[ROW][C]16[/C][C]3.0125[/C][C]22.1958135120851[/C][/ROW]
[ROW][C]17[/C][C]0.5[/C][C]20.2774821608766[/C][/ROW]
[ROW][C]18[/C][C]0[/C][C]18.2997339447889[/C][/ROW]
[ROW][C]19[/C][C]0.875[/C][C]18.2997339447889[/C][/ROW]
[ROW][C]20[/C][C]3.125[/C][C]15.0520550457364[/C][/ROW]
[ROW][C]21[/C][C]10[/C][C]13.9578298121826[/C][/ROW]
[ROW][C]22[/C][C]0[/C][C]13.5917030950519[/C][/ROW]
[ROW][C]23[/C][C]21[/C][C]13.5917030950519[/C][/ROW]
[ROW][C]24[/C][C]0[/C][C]13.0645135486197[/C][/ROW]
[ROW][C]25[/C][C]0.4125[/C][C]13.0645135486197[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75909&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75909&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
146NA
240.546
322.545.45
42543.155
522.2541.3395
6739.43055
71136.187495
850.2533.6687455
916.2535.32687095
1032.533.419183855
115.752533.3272654695
127.7530.56978892255
131428.287810030295
143.526.8590290272655
151.2524.5231261245390
163.012522.1958135120851
170.520.2774821608766
18018.2997339447889
190.87518.2997339447889
203.12515.0520550457364
211013.9578298121826
22013.5917030950519
232113.5917030950519
24013.0645135486197
250.412513.0645135486197







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

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