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 14:17:04 +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/t12737602516bkic54ngzn7x30.htm/, Retrieved Sun, 05 May 2024 22:20:17 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75960, Retrieved Sun, 05 May 2024 22:20:17 +0000
QR Codes:

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

Post a new message
Dataseries X:
42,13333333
43,68333333
9,016666667
33,7
19,09866667
10,06733333
18,81666667
40,85
51,575
16,625
42,6
25,66666667
49,325
39,40833333
37,55333333
57,05
29,575




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75960&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
1836.90144330197834.9595466976253716.015759726839257.787126877117368.8433399063312
1936.90144330197834.8002345043332415.911591082754857.891295521201769.0026520996233
2036.90144330197834.6417090523469815.807936861159857.994949742796769.1611775516096
2136.90144330197834.4839587998817815.704789515286958.098097088669669.3189278040748
2236.90144330197834.3269724846265615.602141681106658.200744922849969.47591411933
2336.90144330197834.1707391143606415.499986171192258.302900432764369.6321474895959
2436.90144330197834.0152479579716615.398315968846458.404570635110169.7876386459849
2536.90144330197833.8604885368539315.297124222477358.505762381479369.9423980671026
2636.90144330197833.7064506166676515.196404240209758.606482363746870.096435987289
2736.90144330197833.5531241994409315.096149484721358.706737119235370.2497624045156

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
18 & 36.9014433019783 & 4.95954669762537 & 16.0157597268392 & 57.7871268771173 & 68.8433399063312 \tabularnewline
19 & 36.9014433019783 & 4.80023450433324 & 15.9115910827548 & 57.8912955212017 & 69.0026520996233 \tabularnewline
20 & 36.9014433019783 & 4.64170905234698 & 15.8079368611598 & 57.9949497427967 & 69.1611775516096 \tabularnewline
21 & 36.9014433019783 & 4.48395879988178 & 15.7047895152869 & 58.0980970886696 & 69.3189278040748 \tabularnewline
22 & 36.9014433019783 & 4.32697248462656 & 15.6021416811066 & 58.2007449228499 & 69.47591411933 \tabularnewline
23 & 36.9014433019783 & 4.17073911436064 & 15.4999861711922 & 58.3029004327643 & 69.6321474895959 \tabularnewline
24 & 36.9014433019783 & 4.01524795797166 & 15.3983159688464 & 58.4045706351101 & 69.7876386459849 \tabularnewline
25 & 36.9014433019783 & 3.86048853685393 & 15.2971242224773 & 58.5057623814793 & 69.9423980671026 \tabularnewline
26 & 36.9014433019783 & 3.70645061666765 & 15.1964042402097 & 58.6064823637468 & 70.096435987289 \tabularnewline
27 & 36.9014433019783 & 3.55312419944093 & 15.0961494847213 & 58.7067371192353 & 70.2497624045156 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75960&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]18[/C][C]36.9014433019783[/C][C]4.95954669762537[/C][C]16.0157597268392[/C][C]57.7871268771173[/C][C]68.8433399063312[/C][/ROW]
[ROW][C]19[/C][C]36.9014433019783[/C][C]4.80023450433324[/C][C]15.9115910827548[/C][C]57.8912955212017[/C][C]69.0026520996233[/C][/ROW]
[ROW][C]20[/C][C]36.9014433019783[/C][C]4.64170905234698[/C][C]15.8079368611598[/C][C]57.9949497427967[/C][C]69.1611775516096[/C][/ROW]
[ROW][C]21[/C][C]36.9014433019783[/C][C]4.48395879988178[/C][C]15.7047895152869[/C][C]58.0980970886696[/C][C]69.3189278040748[/C][/ROW]
[ROW][C]22[/C][C]36.9014433019783[/C][C]4.32697248462656[/C][C]15.6021416811066[/C][C]58.2007449228499[/C][C]69.47591411933[/C][/ROW]
[ROW][C]23[/C][C]36.9014433019783[/C][C]4.17073911436064[/C][C]15.4999861711922[/C][C]58.3029004327643[/C][C]69.6321474895959[/C][/ROW]
[ROW][C]24[/C][C]36.9014433019783[/C][C]4.01524795797166[/C][C]15.3983159688464[/C][C]58.4045706351101[/C][C]69.7876386459849[/C][/ROW]
[ROW][C]25[/C][C]36.9014433019783[/C][C]3.86048853685393[/C][C]15.2971242224773[/C][C]58.5057623814793[/C][C]69.9423980671026[/C][/ROW]
[ROW][C]26[/C][C]36.9014433019783[/C][C]3.70645061666765[/C][C]15.1964042402097[/C][C]58.6064823637468[/C][C]70.096435987289[/C][/ROW]
[ROW][C]27[/C][C]36.9014433019783[/C][C]3.55312419944093[/C][C]15.0961494847213[/C][C]58.7067371192353[/C][C]70.2497624045156[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75960&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75960&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
1836.90144330197834.9595466976253716.015759726839257.787126877117368.8433399063312
1936.90144330197834.8002345043332415.911591082754857.891295521201769.0026520996233
2036.90144330197834.6417090523469815.807936861159857.994949742796769.1611775516096
2136.90144330197834.4839587998817815.704789515286958.098097088669669.3189278040748
2236.90144330197834.3269724846265615.602141681106658.200744922849969.47591411933
2336.90144330197834.1707391143606415.499986171192258.302900432764369.6321474895959
2436.90144330197834.0152479579716615.398315968846458.404570635110169.7876386459849
2536.90144330197833.8604885368539315.297124222477358.505762381479369.9423980671026
2636.90144330197833.7064506166676515.196404240209758.606482363746870.096435987289
2736.90144330197833.5531241994409315.096149484721358.706737119235370.2497624045156







Actuals and Interpolation
TimeActualForecast
142.13333333NA
243.6833333342.13333333
39.01666666742.28833333
433.738.9611666637
519.0986666738.43504999733
610.0673333336.501411664597
718.8166666733.8580038311373
840.8532.3538701150236
951.57533.2034831035212
1016.62535.0406347931691
1142.633.1990713138522
1225.6666666734.139164182467
1349.32533.2919144312203
1439.4083333334.8952229880983
1537.5533333335.3465340222884
1657.0535.5672139530596
1729.57537.7154925577536

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 42.13333333 & NA \tabularnewline
2 & 43.68333333 & 42.13333333 \tabularnewline
3 & 9.016666667 & 42.28833333 \tabularnewline
4 & 33.7 & 38.9611666637 \tabularnewline
5 & 19.09866667 & 38.43504999733 \tabularnewline
6 & 10.06733333 & 36.501411664597 \tabularnewline
7 & 18.81666667 & 33.8580038311373 \tabularnewline
8 & 40.85 & 32.3538701150236 \tabularnewline
9 & 51.575 & 33.2034831035212 \tabularnewline
10 & 16.625 & 35.0406347931691 \tabularnewline
11 & 42.6 & 33.1990713138522 \tabularnewline
12 & 25.66666667 & 34.139164182467 \tabularnewline
13 & 49.325 & 33.2919144312203 \tabularnewline
14 & 39.40833333 & 34.8952229880983 \tabularnewline
15 & 37.55333333 & 35.3465340222884 \tabularnewline
16 & 57.05 & 35.5672139530596 \tabularnewline
17 & 29.575 & 37.7154925577536 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75960&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]42.13333333[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]43.68333333[/C][C]42.13333333[/C][/ROW]
[ROW][C]3[/C][C]9.016666667[/C][C]42.28833333[/C][/ROW]
[ROW][C]4[/C][C]33.7[/C][C]38.9611666637[/C][/ROW]
[ROW][C]5[/C][C]19.09866667[/C][C]38.43504999733[/C][/ROW]
[ROW][C]6[/C][C]10.06733333[/C][C]36.501411664597[/C][/ROW]
[ROW][C]7[/C][C]18.81666667[/C][C]33.8580038311373[/C][/ROW]
[ROW][C]8[/C][C]40.85[/C][C]32.3538701150236[/C][/ROW]
[ROW][C]9[/C][C]51.575[/C][C]33.2034831035212[/C][/ROW]
[ROW][C]10[/C][C]16.625[/C][C]35.0406347931691[/C][/ROW]
[ROW][C]11[/C][C]42.6[/C][C]33.1990713138522[/C][/ROW]
[ROW][C]12[/C][C]25.66666667[/C][C]34.139164182467[/C][/ROW]
[ROW][C]13[/C][C]49.325[/C][C]33.2919144312203[/C][/ROW]
[ROW][C]14[/C][C]39.40833333[/C][C]34.8952229880983[/C][/ROW]
[ROW][C]15[/C][C]37.55333333[/C][C]35.3465340222884[/C][/ROW]
[ROW][C]16[/C][C]57.05[/C][C]35.5672139530596[/C][/ROW]
[ROW][C]17[/C][C]29.575[/C][C]37.7154925577536[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75960&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75960&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
142.13333333NA
243.6833333342.13333333
39.01666666742.28833333
433.738.9611666637
519.0986666738.43504999733
610.0673333336.501411664597
718.8166666733.8580038311373
840.8532.3538701150236
951.57533.2034831035212
1016.62535.0406347931691
1142.633.1990713138522
1225.6666666734.139164182467
1349.32533.2919144312203
1439.4083333334.8952229880983
1537.5533333335.3465340222884
1657.0535.5672139530596
1729.57537.7154925577536







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

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