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:05:15 +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/t1273755952a33qxbxmpjzzjht.htm/, Retrieved Mon, 06 May 2024 04:02:14 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75918, Retrieved Mon, 06 May 2024 04:02:14 +0000
QR Codes:

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

Post a new message
Dataseries X:
66
71
50
66
66
44
76,75
66
65,75
76,75
65
76
88
75,5
97,5
98
88,0115
55,25
88,25
87
75,5
88
74,5
63,5
94




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

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







Demand Forecast
PointForecast95% LB80% LB80% UB95% UB
2677.802907562662951.497942989867260.603015730072695.0027993952532104.107872135459
2777.802907562662951.366745345204160.517230201236395.0885849240894104.239069780122
2877.802907562662951.236195602023960.43186831240995.1739468129168104.369619523302
2977.802907562662951.106284255373360.346923848635595.2588912766903104.499530869952
3077.802907562662950.977002030452460.262390745450395.3434243798755104.628813094873
3177.802907562662950.84833987488860.178263083824595.4275520415012104.757475250438
3277.802907562662950.720288951335860.094535085329695.5112800399962104.88552617399
3377.802907562662950.592840630397660.011201107505195.5946140178206105.012974494928
3477.802907562662950.46598648383459.928255639421795.677559485904105.139828641492
3577.802907562662950.339718278060859.845693297427995.7601218278979105.266096847265

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
26 & 77.8029075626629 & 51.4979429898672 & 60.6030157300726 & 95.0027993952532 & 104.107872135459 \tabularnewline
27 & 77.8029075626629 & 51.3667453452041 & 60.5172302012363 & 95.0885849240894 & 104.239069780122 \tabularnewline
28 & 77.8029075626629 & 51.2361956020239 & 60.431868312409 & 95.1739468129168 & 104.369619523302 \tabularnewline
29 & 77.8029075626629 & 51.1062842553733 & 60.3469238486355 & 95.2588912766903 & 104.499530869952 \tabularnewline
30 & 77.8029075626629 & 50.9770020304524 & 60.2623907454503 & 95.3434243798755 & 104.628813094873 \tabularnewline
31 & 77.8029075626629 & 50.848339874888 & 60.1782630838245 & 95.4275520415012 & 104.757475250438 \tabularnewline
32 & 77.8029075626629 & 50.7202889513358 & 60.0945350853296 & 95.5112800399962 & 104.88552617399 \tabularnewline
33 & 77.8029075626629 & 50.5928406303976 & 60.0112011075051 & 95.5946140178206 & 105.012974494928 \tabularnewline
34 & 77.8029075626629 & 50.465986483834 & 59.9282556394217 & 95.677559485904 & 105.139828641492 \tabularnewline
35 & 77.8029075626629 & 50.3397182780608 & 59.8456932974279 & 95.7601218278979 & 105.266096847265 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75918&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]77.8029075626629[/C][C]51.4979429898672[/C][C]60.6030157300726[/C][C]95.0027993952532[/C][C]104.107872135459[/C][/ROW]
[ROW][C]27[/C][C]77.8029075626629[/C][C]51.3667453452041[/C][C]60.5172302012363[/C][C]95.0885849240894[/C][C]104.239069780122[/C][/ROW]
[ROW][C]28[/C][C]77.8029075626629[/C][C]51.2361956020239[/C][C]60.431868312409[/C][C]95.1739468129168[/C][C]104.369619523302[/C][/ROW]
[ROW][C]29[/C][C]77.8029075626629[/C][C]51.1062842553733[/C][C]60.3469238486355[/C][C]95.2588912766903[/C][C]104.499530869952[/C][/ROW]
[ROW][C]30[/C][C]77.8029075626629[/C][C]50.9770020304524[/C][C]60.2623907454503[/C][C]95.3434243798755[/C][C]104.628813094873[/C][/ROW]
[ROW][C]31[/C][C]77.8029075626629[/C][C]50.848339874888[/C][C]60.1782630838245[/C][C]95.4275520415012[/C][C]104.757475250438[/C][/ROW]
[ROW][C]32[/C][C]77.8029075626629[/C][C]50.7202889513358[/C][C]60.0945350853296[/C][C]95.5112800399962[/C][C]104.88552617399[/C][/ROW]
[ROW][C]33[/C][C]77.8029075626629[/C][C]50.5928406303976[/C][C]60.0112011075051[/C][C]95.5946140178206[/C][C]105.012974494928[/C][/ROW]
[ROW][C]34[/C][C]77.8029075626629[/C][C]50.465986483834[/C][C]59.9282556394217[/C][C]95.677559485904[/C][C]105.139828641492[/C][/ROW]
[ROW][C]35[/C][C]77.8029075626629[/C][C]50.3397182780608[/C][C]59.8456932974279[/C][C]95.7601218278979[/C][C]105.266096847265[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75918&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75918&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
2677.802907562662951.497942989867260.603015730072695.0027993952532104.107872135459
2777.802907562662951.366745345204160.517230201236395.0885849240894104.239069780122
2877.802907562662951.236195602023960.43186831240995.1739468129168104.369619523302
2977.802907562662951.106284255373360.346923848635595.2588912766903104.499530869952
3077.802907562662950.977002030452460.262390745450395.3434243798755104.628813094873
3177.802907562662950.84833987488860.178263083824595.4275520415012104.757475250438
3277.802907562662950.720288951335860.094535085329695.5112800399962104.88552617399
3377.802907562662950.592840630397660.011201107505195.5946140178206105.012974494928
3477.802907562662950.46598648383459.928255639421795.677559485904105.139828641492
3577.802907562662950.339718278060859.845693297427995.7601218278979105.266096847265







Actuals and Interpolation
TimeActualForecast
166NA
27166
35066.5
46664.85
56664.965
64465.0685
776.7562.96165
86664.340485
965.7564.5064365
1076.7564.63079285
116565.842713565
127665.7584422085
138866.78259798765
1475.568.904338188885
1597.569.5639043699965
169872.3575139329969
1788.011574.9217625396972
1855.2576.2307362857275
1988.2574.1326626571547
208775.5443963914393
2175.576.6899567522953
228876.5709610770658
2374.577.7138649693592
2463.577.3924784724233
259476.003230625181

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 66 & NA \tabularnewline
2 & 71 & 66 \tabularnewline
3 & 50 & 66.5 \tabularnewline
4 & 66 & 64.85 \tabularnewline
5 & 66 & 64.965 \tabularnewline
6 & 44 & 65.0685 \tabularnewline
7 & 76.75 & 62.96165 \tabularnewline
8 & 66 & 64.340485 \tabularnewline
9 & 65.75 & 64.5064365 \tabularnewline
10 & 76.75 & 64.63079285 \tabularnewline
11 & 65 & 65.842713565 \tabularnewline
12 & 76 & 65.7584422085 \tabularnewline
13 & 88 & 66.78259798765 \tabularnewline
14 & 75.5 & 68.904338188885 \tabularnewline
15 & 97.5 & 69.5639043699965 \tabularnewline
16 & 98 & 72.3575139329969 \tabularnewline
17 & 88.0115 & 74.9217625396972 \tabularnewline
18 & 55.25 & 76.2307362857275 \tabularnewline
19 & 88.25 & 74.1326626571547 \tabularnewline
20 & 87 & 75.5443963914393 \tabularnewline
21 & 75.5 & 76.6899567522953 \tabularnewline
22 & 88 & 76.5709610770658 \tabularnewline
23 & 74.5 & 77.7138649693592 \tabularnewline
24 & 63.5 & 77.3924784724233 \tabularnewline
25 & 94 & 76.003230625181 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75918&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]66[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]71[/C][C]66[/C][/ROW]
[ROW][C]3[/C][C]50[/C][C]66.5[/C][/ROW]
[ROW][C]4[/C][C]66[/C][C]64.85[/C][/ROW]
[ROW][C]5[/C][C]66[/C][C]64.965[/C][/ROW]
[ROW][C]6[/C][C]44[/C][C]65.0685[/C][/ROW]
[ROW][C]7[/C][C]76.75[/C][C]62.96165[/C][/ROW]
[ROW][C]8[/C][C]66[/C][C]64.340485[/C][/ROW]
[ROW][C]9[/C][C]65.75[/C][C]64.5064365[/C][/ROW]
[ROW][C]10[/C][C]76.75[/C][C]64.63079285[/C][/ROW]
[ROW][C]11[/C][C]65[/C][C]65.842713565[/C][/ROW]
[ROW][C]12[/C][C]76[/C][C]65.7584422085[/C][/ROW]
[ROW][C]13[/C][C]88[/C][C]66.78259798765[/C][/ROW]
[ROW][C]14[/C][C]75.5[/C][C]68.904338188885[/C][/ROW]
[ROW][C]15[/C][C]97.5[/C][C]69.5639043699965[/C][/ROW]
[ROW][C]16[/C][C]98[/C][C]72.3575139329969[/C][/ROW]
[ROW][C]17[/C][C]88.0115[/C][C]74.9217625396972[/C][/ROW]
[ROW][C]18[/C][C]55.25[/C][C]76.2307362857275[/C][/ROW]
[ROW][C]19[/C][C]88.25[/C][C]74.1326626571547[/C][/ROW]
[ROW][C]20[/C][C]87[/C][C]75.5443963914393[/C][/ROW]
[ROW][C]21[/C][C]75.5[/C][C]76.6899567522953[/C][/ROW]
[ROW][C]22[/C][C]88[/C][C]76.5709610770658[/C][/ROW]
[ROW][C]23[/C][C]74.5[/C][C]77.7138649693592[/C][/ROW]
[ROW][C]24[/C][C]63.5[/C][C]77.3924784724233[/C][/ROW]
[ROW][C]25[/C][C]94[/C][C]76.003230625181[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75918&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75918&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
166NA
27166
35066.5
46664.85
56664.965
64465.0685
776.7562.96165
86664.340485
965.7564.5064365
1076.7564.63079285
116565.842713565
127665.7584422085
138866.78259798765
1475.568.904338188885
1597.569.5639043699965
169872.3575139329969
1788.011574.9217625396972
1855.2576.2307362857275
1988.2574.1326626571547
208775.5443963914393
2175.576.6899567522953
228876.5709610770658
2374.577.7138649693592
2463.577.3924784724233
259476.003230625181







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

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