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:06:48 +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/t1273759641qf7754130nz8r8z.htm/, Retrieved Mon, 06 May 2024 09:23:44 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75951, Retrieved Mon, 06 May 2024 09:23:44 +0000
QR Codes:

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

Post a new message
Dataseries X:
341,95
326,3416667
317,3416667
440,867
433,034
477,3506667
488,225
463,4333333
384,25
273,675
268,1666667
226,6916667
248,8333333
224,75
188,0083333
194,8916667
145,875




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

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







Demand Forecast
PointForecast95% LB80% LB80% UB95% UB
18288.07129719662182.6403613625606153.74722823103422.395366162211493.502233030681
19288.07129719662181.6157618103436153.077278593915423.065315799326494.526832582898
20288.07129719662180.5962221017773152.410637410733423.731956982508495.546372291464
21288.07129719662179.5816680070913151.747256145246424.395338247995496.56092638615
22288.07129719662178.5720270939206151.087087436475425.055506956767497.570567299321
23288.07129719662177.5672286669587150.430085059244425.712509333998498.575365726282
24288.07129719662176.567203710189149.776203886405426.366390506836499.575390683052
25288.07129719662175.5718848315655149.125399852669427.017194540572500.570709561676
26288.07129719662174.5812062100123148.477629919947427.664964473294501.561388183229
27288.07129719662173.5951035446283147.83285204414428.309742349101502.547490848613

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
18 & 288.071297196621 & 82.6403613625606 & 153.74722823103 & 422.395366162211 & 493.502233030681 \tabularnewline
19 & 288.071297196621 & 81.6157618103436 & 153.077278593915 & 423.065315799326 & 494.526832582898 \tabularnewline
20 & 288.071297196621 & 80.5962221017773 & 152.410637410733 & 423.731956982508 & 495.546372291464 \tabularnewline
21 & 288.071297196621 & 79.5816680070913 & 151.747256145246 & 424.395338247995 & 496.56092638615 \tabularnewline
22 & 288.071297196621 & 78.5720270939206 & 151.087087436475 & 425.055506956767 & 497.570567299321 \tabularnewline
23 & 288.071297196621 & 77.5672286669587 & 150.430085059244 & 425.712509333998 & 498.575365726282 \tabularnewline
24 & 288.071297196621 & 76.567203710189 & 149.776203886405 & 426.366390506836 & 499.575390683052 \tabularnewline
25 & 288.071297196621 & 75.5718848315655 & 149.125399852669 & 427.017194540572 & 500.570709561676 \tabularnewline
26 & 288.071297196621 & 74.5812062100123 & 148.477629919947 & 427.664964473294 & 501.561388183229 \tabularnewline
27 & 288.071297196621 & 73.5951035446283 & 147.83285204414 & 428.309742349101 & 502.547490848613 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75951&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]288.071297196621[/C][C]82.6403613625606[/C][C]153.74722823103[/C][C]422.395366162211[/C][C]493.502233030681[/C][/ROW]
[ROW][C]19[/C][C]288.071297196621[/C][C]81.6157618103436[/C][C]153.077278593915[/C][C]423.065315799326[/C][C]494.526832582898[/C][/ROW]
[ROW][C]20[/C][C]288.071297196621[/C][C]80.5962221017773[/C][C]152.410637410733[/C][C]423.731956982508[/C][C]495.546372291464[/C][/ROW]
[ROW][C]21[/C][C]288.071297196621[/C][C]79.5816680070913[/C][C]151.747256145246[/C][C]424.395338247995[/C][C]496.56092638615[/C][/ROW]
[ROW][C]22[/C][C]288.071297196621[/C][C]78.5720270939206[/C][C]151.087087436475[/C][C]425.055506956767[/C][C]497.570567299321[/C][/ROW]
[ROW][C]23[/C][C]288.071297196621[/C][C]77.5672286669587[/C][C]150.430085059244[/C][C]425.712509333998[/C][C]498.575365726282[/C][/ROW]
[ROW][C]24[/C][C]288.071297196621[/C][C]76.567203710189[/C][C]149.776203886405[/C][C]426.366390506836[/C][C]499.575390683052[/C][/ROW]
[ROW][C]25[/C][C]288.071297196621[/C][C]75.5718848315655[/C][C]149.125399852669[/C][C]427.017194540572[/C][C]500.570709561676[/C][/ROW]
[ROW][C]26[/C][C]288.071297196621[/C][C]74.5812062100123[/C][C]148.477629919947[/C][C]427.664964473294[/C][C]501.561388183229[/C][/ROW]
[ROW][C]27[/C][C]288.071297196621[/C][C]73.5951035446283[/C][C]147.83285204414[/C][C]428.309742349101[/C][C]502.547490848613[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75951&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75951&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
18288.07129719662182.6403613625606153.74722823103422.395366162211493.502233030681
19288.07129719662181.6157618103436153.077278593915423.065315799326494.526832582898
20288.07129719662180.5962221017773152.410637410733423.731956982508495.546372291464
21288.07129719662179.5816680070913151.747256145246424.395338247995496.56092638615
22288.07129719662178.5720270939206151.087087436475425.055506956767497.570567299321
23288.07129719662177.5672286669587150.430085059244425.712509333998498.575365726282
24288.07129719662176.567203710189149.776203886405426.366390506836499.575390683052
25288.07129719662175.5718848315655149.125399852669427.017194540572500.570709561676
26288.07129719662174.5812062100123148.477629919947427.664964473294501.561388183229
27288.07129719662173.5951035446283147.83285204414428.309742349101502.547490848613







Actuals and Interpolation
TimeActualForecast
1341.95NA
2326.3416667341.95
3317.3416667340.38916667
4440.867338.084416673
5433.034348.3626750057
6477.3506667356.82980750513
7488.225368.881893424617
8463.4333333380.816204082155
9384.25389.07791700394
10273.675388.595125303546
11268.1666667377.103112773191
12226.6916667366.209468165872
13248.8333333352.257688019285
14224.75341.915252547356
15188.0083333330.198727292621
16194.8916667315.979687893359
17145.875303.870885774023

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 341.95 & NA \tabularnewline
2 & 326.3416667 & 341.95 \tabularnewline
3 & 317.3416667 & 340.38916667 \tabularnewline
4 & 440.867 & 338.084416673 \tabularnewline
5 & 433.034 & 348.3626750057 \tabularnewline
6 & 477.3506667 & 356.82980750513 \tabularnewline
7 & 488.225 & 368.881893424617 \tabularnewline
8 & 463.4333333 & 380.816204082155 \tabularnewline
9 & 384.25 & 389.07791700394 \tabularnewline
10 & 273.675 & 388.595125303546 \tabularnewline
11 & 268.1666667 & 377.103112773191 \tabularnewline
12 & 226.6916667 & 366.209468165872 \tabularnewline
13 & 248.8333333 & 352.257688019285 \tabularnewline
14 & 224.75 & 341.915252547356 \tabularnewline
15 & 188.0083333 & 330.198727292621 \tabularnewline
16 & 194.8916667 & 315.979687893359 \tabularnewline
17 & 145.875 & 303.870885774023 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75951&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]341.95[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]326.3416667[/C][C]341.95[/C][/ROW]
[ROW][C]3[/C][C]317.3416667[/C][C]340.38916667[/C][/ROW]
[ROW][C]4[/C][C]440.867[/C][C]338.084416673[/C][/ROW]
[ROW][C]5[/C][C]433.034[/C][C]348.3626750057[/C][/ROW]
[ROW][C]6[/C][C]477.3506667[/C][C]356.82980750513[/C][/ROW]
[ROW][C]7[/C][C]488.225[/C][C]368.881893424617[/C][/ROW]
[ROW][C]8[/C][C]463.4333333[/C][C]380.816204082155[/C][/ROW]
[ROW][C]9[/C][C]384.25[/C][C]389.07791700394[/C][/ROW]
[ROW][C]10[/C][C]273.675[/C][C]388.595125303546[/C][/ROW]
[ROW][C]11[/C][C]268.1666667[/C][C]377.103112773191[/C][/ROW]
[ROW][C]12[/C][C]226.6916667[/C][C]366.209468165872[/C][/ROW]
[ROW][C]13[/C][C]248.8333333[/C][C]352.257688019285[/C][/ROW]
[ROW][C]14[/C][C]224.75[/C][C]341.915252547356[/C][/ROW]
[ROW][C]15[/C][C]188.0083333[/C][C]330.198727292621[/C][/ROW]
[ROW][C]16[/C][C]194.8916667[/C][C]315.979687893359[/C][/ROW]
[ROW][C]17[/C][C]145.875[/C][C]303.870885774023[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75951&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75951&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
1341.95NA
2326.3416667341.95
3317.3416667340.38916667
4440.867338.084416673
5433.034348.3626750057
6477.3506667356.82980750513
7488.225368.881893424617
8463.4333333380.816204082155
9384.25389.07791700394
10273.675388.595125303546
11268.1666667377.103112773191
12226.6916667366.209468165872
13248.8333333352.257688019285
14224.75341.915252547356
15188.0083333330.198727292621
16194.8916667315.979687893359
17145.875303.870885774023







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

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