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:58:12 +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/t1273759135tiznozraj42xlq9.htm/, Retrieved Tue, 07 May 2024 15:17:26 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75945, Retrieved Tue, 07 May 2024 15:17:26 +0000
QR Codes:

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

Post a new message
Dataseries X:
266,75
275,9833333
265,1016667
203,9416667
193,25
243,9416667
219,6583333
131,4436667
144,1833333
207,4166667
117,0666667
58,66666667
145,7583333
206,7033333
149,7666667
87,06666667
121,9083333




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75945&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
18174.82738902606978.1193249789766111.593384800515238.061393251623271.535453073162
19174.82738902606977.6369875028019111.278001276844238.376776775294272.017790549337
20174.82738902606977.1570319837644110.964175231230238.690602820909272.497746068374
21174.82738902606976.6794234776756110.651883814896239.002894237243272.975354574463
22174.82738902606976.204127886488110.341104732328239.313673319811273.450650165651
23174.82738902606975.7311119298867110.031816222696239.622961829443273.923666122252
24174.82738902606975.2603431180944109.723997042078239.930781010061274.394434934045
25174.82738902606974.7917897258295109.417626446427240.237151605712274.862988326309
26174.82738902606974.3254207673555109.112684175259240.54209387688275.329357284783
27174.82738902606973.8612059725693108.809150436017240.845627616122275.793572079570

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
18 & 174.827389026069 & 78.1193249789766 & 111.593384800515 & 238.061393251623 & 271.535453073162 \tabularnewline
19 & 174.827389026069 & 77.6369875028019 & 111.278001276844 & 238.376776775294 & 272.017790549337 \tabularnewline
20 & 174.827389026069 & 77.1570319837644 & 110.964175231230 & 238.690602820909 & 272.497746068374 \tabularnewline
21 & 174.827389026069 & 76.6794234776756 & 110.651883814896 & 239.002894237243 & 272.975354574463 \tabularnewline
22 & 174.827389026069 & 76.204127886488 & 110.341104732328 & 239.313673319811 & 273.450650165651 \tabularnewline
23 & 174.827389026069 & 75.7311119298867 & 110.031816222696 & 239.622961829443 & 273.923666122252 \tabularnewline
24 & 174.827389026069 & 75.2603431180944 & 109.723997042078 & 239.930781010061 & 274.394434934045 \tabularnewline
25 & 174.827389026069 & 74.7917897258295 & 109.417626446427 & 240.237151605712 & 274.862988326309 \tabularnewline
26 & 174.827389026069 & 74.3254207673555 & 109.112684175259 & 240.54209387688 & 275.329357284783 \tabularnewline
27 & 174.827389026069 & 73.8612059725693 & 108.809150436017 & 240.845627616122 & 275.793572079570 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75945&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]174.827389026069[/C][C]78.1193249789766[/C][C]111.593384800515[/C][C]238.061393251623[/C][C]271.535453073162[/C][/ROW]
[ROW][C]19[/C][C]174.827389026069[/C][C]77.6369875028019[/C][C]111.278001276844[/C][C]238.376776775294[/C][C]272.017790549337[/C][/ROW]
[ROW][C]20[/C][C]174.827389026069[/C][C]77.1570319837644[/C][C]110.964175231230[/C][C]238.690602820909[/C][C]272.497746068374[/C][/ROW]
[ROW][C]21[/C][C]174.827389026069[/C][C]76.6794234776756[/C][C]110.651883814896[/C][C]239.002894237243[/C][C]272.975354574463[/C][/ROW]
[ROW][C]22[/C][C]174.827389026069[/C][C]76.204127886488[/C][C]110.341104732328[/C][C]239.313673319811[/C][C]273.450650165651[/C][/ROW]
[ROW][C]23[/C][C]174.827389026069[/C][C]75.7311119298867[/C][C]110.031816222696[/C][C]239.622961829443[/C][C]273.923666122252[/C][/ROW]
[ROW][C]24[/C][C]174.827389026069[/C][C]75.2603431180944[/C][C]109.723997042078[/C][C]239.930781010061[/C][C]274.394434934045[/C][/ROW]
[ROW][C]25[/C][C]174.827389026069[/C][C]74.7917897258295[/C][C]109.417626446427[/C][C]240.237151605712[/C][C]274.862988326309[/C][/ROW]
[ROW][C]26[/C][C]174.827389026069[/C][C]74.3254207673555[/C][C]109.112684175259[/C][C]240.54209387688[/C][C]275.329357284783[/C][/ROW]
[ROW][C]27[/C][C]174.827389026069[/C][C]73.8612059725693[/C][C]108.809150436017[/C][C]240.845627616122[/C][C]275.793572079570[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75945&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75945&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
18174.82738902606978.1193249789766111.593384800515238.061393251623271.535453073162
19174.82738902606977.6369875028019111.278001276844238.376776775294272.017790549337
20174.82738902606977.1570319837644110.964175231230238.690602820909272.497746068374
21174.82738902606976.6794234776756110.651883814896239.002894237243272.975354574463
22174.82738902606976.204127886488110.341104732328239.313673319811273.450650165651
23174.82738902606975.7311119298867110.031816222696239.622961829443273.923666122252
24174.82738902606975.2603431180944109.723997042078239.930781010061274.394434934045
25174.82738902606974.7917897258295109.417626446427240.237151605712274.862988326309
26174.82738902606974.3254207673555109.112684175259240.54209387688275.329357284783
27174.82738902606973.8612059725693108.809150436017240.845627616122275.793572079570







Actuals and Interpolation
TimeActualForecast
1266.75NA
2275.9833333266.75
3265.1016667267.67333333
4203.9416667267.416166667
5193.25261.0687166703
6243.9416667254.28684500327
7219.6583333253.252327172943
8131.4436667249.892927785649
9144.1833333238.048001677084
10207.4166667228.661534839376
11117.0666667226.537048025438
1258.66666667215.590009892894
13145.7583333199.897675570605
14206.7033333194.483741343544
15149.7666667195.70570053919
1687.06666667191.111797155271
17121.9083333180.707284106744

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 266.75 & NA \tabularnewline
2 & 275.9833333 & 266.75 \tabularnewline
3 & 265.1016667 & 267.67333333 \tabularnewline
4 & 203.9416667 & 267.416166667 \tabularnewline
5 & 193.25 & 261.0687166703 \tabularnewline
6 & 243.9416667 & 254.28684500327 \tabularnewline
7 & 219.6583333 & 253.252327172943 \tabularnewline
8 & 131.4436667 & 249.892927785649 \tabularnewline
9 & 144.1833333 & 238.048001677084 \tabularnewline
10 & 207.4166667 & 228.661534839376 \tabularnewline
11 & 117.0666667 & 226.537048025438 \tabularnewline
12 & 58.66666667 & 215.590009892894 \tabularnewline
13 & 145.7583333 & 199.897675570605 \tabularnewline
14 & 206.7033333 & 194.483741343544 \tabularnewline
15 & 149.7666667 & 195.70570053919 \tabularnewline
16 & 87.06666667 & 191.111797155271 \tabularnewline
17 & 121.9083333 & 180.707284106744 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75945&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]266.75[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]275.9833333[/C][C]266.75[/C][/ROW]
[ROW][C]3[/C][C]265.1016667[/C][C]267.67333333[/C][/ROW]
[ROW][C]4[/C][C]203.9416667[/C][C]267.416166667[/C][/ROW]
[ROW][C]5[/C][C]193.25[/C][C]261.0687166703[/C][/ROW]
[ROW][C]6[/C][C]243.9416667[/C][C]254.28684500327[/C][/ROW]
[ROW][C]7[/C][C]219.6583333[/C][C]253.252327172943[/C][/ROW]
[ROW][C]8[/C][C]131.4436667[/C][C]249.892927785649[/C][/ROW]
[ROW][C]9[/C][C]144.1833333[/C][C]238.048001677084[/C][/ROW]
[ROW][C]10[/C][C]207.4166667[/C][C]228.661534839376[/C][/ROW]
[ROW][C]11[/C][C]117.0666667[/C][C]226.537048025438[/C][/ROW]
[ROW][C]12[/C][C]58.66666667[/C][C]215.590009892894[/C][/ROW]
[ROW][C]13[/C][C]145.7583333[/C][C]199.897675570605[/C][/ROW]
[ROW][C]14[/C][C]206.7033333[/C][C]194.483741343544[/C][/ROW]
[ROW][C]15[/C][C]149.7666667[/C][C]195.70570053919[/C][/ROW]
[ROW][C]16[/C][C]87.06666667[/C][C]191.111797155271[/C][/ROW]
[ROW][C]17[/C][C]121.9083333[/C][C]180.707284106744[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75945&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75945&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
1266.75NA
2275.9833333266.75
3265.1016667267.67333333
4203.9416667267.416166667
5193.25261.0687166703
6243.9416667254.28684500327
7219.6583333253.252327172943
8131.4436667249.892927785649
9144.1833333238.048001677084
10207.4166667228.661534839376
11117.0666667226.537048025438
1258.66666667215.590009892894
13145.7583333199.897675570605
14206.7033333194.483741343544
15149.7666667195.70570053919
1687.06666667191.111797155271
17121.9083333180.707284106744







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

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