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

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

Post a new message
Dataseries X:
192
212.25
191.8
163.7625
272.025
284.575
301.6635
287.5375
220.4375
178.3
284.8875
283.9875
238
216.275
162.875
185.95
193.7875
128.3275
83.925
177.15
142.3
120.5375
269.25
167.625
243.275




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75925&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
26193.98202275115372.6195530427161114.627369155462273.336676346844315.34449245959
27193.98202275115372.0142501869688114.23158289177273.732462610536315.949795315338
28193.98202275115371.4119365359353113.837751163984274.126294338323316.552108966371
29193.98202275115370.8125682368815113.445845298341274.518200203966317.151477265425
30193.98202275115370.2161024989264113.055837315388274.908208186918317.74794300338
31193.98202275115369.6224975573914112.667699906670275.296345595636318.341547944915
32193.98202275115369.0317126396725112.281406412415275.682639089891318.932332862634
33193.98202275115368.4437079325588111.896930800162276.067114702144319.520337569748
34193.98202275115367.858444550922111.514247644294276.449797858013320.105600951384
35193.98202275115367.2758845077076111.133332106409276.830713395897320.688160994599

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
26 & 193.982022751153 & 72.6195530427161 & 114.627369155462 & 273.336676346844 & 315.34449245959 \tabularnewline
27 & 193.982022751153 & 72.0142501869688 & 114.23158289177 & 273.732462610536 & 315.949795315338 \tabularnewline
28 & 193.982022751153 & 71.4119365359353 & 113.837751163984 & 274.126294338323 & 316.552108966371 \tabularnewline
29 & 193.982022751153 & 70.8125682368815 & 113.445845298341 & 274.518200203966 & 317.151477265425 \tabularnewline
30 & 193.982022751153 & 70.2161024989264 & 113.055837315388 & 274.908208186918 & 317.74794300338 \tabularnewline
31 & 193.982022751153 & 69.6224975573914 & 112.667699906670 & 275.296345595636 & 318.341547944915 \tabularnewline
32 & 193.982022751153 & 69.0317126396725 & 112.281406412415 & 275.682639089891 & 318.932332862634 \tabularnewline
33 & 193.982022751153 & 68.4437079325588 & 111.896930800162 & 276.067114702144 & 319.520337569748 \tabularnewline
34 & 193.982022751153 & 67.858444550922 & 111.514247644294 & 276.449797858013 & 320.105600951384 \tabularnewline
35 & 193.982022751153 & 67.2758845077076 & 111.133332106409 & 276.830713395897 & 320.688160994599 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75925&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]193.982022751153[/C][C]72.6195530427161[/C][C]114.627369155462[/C][C]273.336676346844[/C][C]315.34449245959[/C][/ROW]
[ROW][C]27[/C][C]193.982022751153[/C][C]72.0142501869688[/C][C]114.23158289177[/C][C]273.732462610536[/C][C]315.949795315338[/C][/ROW]
[ROW][C]28[/C][C]193.982022751153[/C][C]71.4119365359353[/C][C]113.837751163984[/C][C]274.126294338323[/C][C]316.552108966371[/C][/ROW]
[ROW][C]29[/C][C]193.982022751153[/C][C]70.8125682368815[/C][C]113.445845298341[/C][C]274.518200203966[/C][C]317.151477265425[/C][/ROW]
[ROW][C]30[/C][C]193.982022751153[/C][C]70.2161024989264[/C][C]113.055837315388[/C][C]274.908208186918[/C][C]317.74794300338[/C][/ROW]
[ROW][C]31[/C][C]193.982022751153[/C][C]69.6224975573914[/C][C]112.667699906670[/C][C]275.296345595636[/C][C]318.341547944915[/C][/ROW]
[ROW][C]32[/C][C]193.982022751153[/C][C]69.0317126396725[/C][C]112.281406412415[/C][C]275.682639089891[/C][C]318.932332862634[/C][/ROW]
[ROW][C]33[/C][C]193.982022751153[/C][C]68.4437079325588[/C][C]111.896930800162[/C][C]276.067114702144[/C][C]319.520337569748[/C][/ROW]
[ROW][C]34[/C][C]193.982022751153[/C][C]67.858444550922[/C][C]111.514247644294[/C][C]276.449797858013[/C][C]320.105600951384[/C][/ROW]
[ROW][C]35[/C][C]193.982022751153[/C][C]67.2758845077076[/C][C]111.133332106409[/C][C]276.830713395897[/C][C]320.688160994599[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75925&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75925&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
26193.98202275115372.6195530427161114.627369155462273.336676346844315.34449245959
27193.98202275115372.0142501869688114.23158289177273.732462610536315.949795315338
28193.98202275115371.4119365359353113.837751163984274.126294338323316.552108966371
29193.98202275115370.8125682368815113.445845298341274.518200203966317.151477265425
30193.98202275115370.2161024989264113.055837315388274.908208186918317.74794300338
31193.98202275115369.6224975573914112.667699906670275.296345595636318.341547944915
32193.98202275115369.0317126396725112.281406412415275.682639089891318.932332862634
33193.98202275115368.4437079325588111.896930800162276.067114702144319.520337569748
34193.98202275115367.858444550922111.514247644294276.449797858013320.105600951384
35193.98202275115367.2758845077076111.133332106409276.830713395897320.688160994599







Actuals and Interpolation
TimeActualForecast
1192NA
2212.25192
3191.8194.025
4163.7625193.8025
5272.025190.7985
6284.575198.92115
7301.6635207.486535
8287.5375216.9042315
9220.4375223.96755835
10178.3223.614552515
11284.8875219.0830972635
12283.9875225.66353753715
13238231.495933783435
14216.275232.146340405092
15162.875230.559206364582
16185.95223.790785728124
17193.7875220.006707155312
18128.3275217.384786439781
1983.925208.479057795803
20177.15196.023652016222
21142.3194.1362868146
22120.5375188.95265813314
23269.25182.111142319826
24167.625190.825028087843
25243.275188.505025279059

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 192 & NA \tabularnewline
2 & 212.25 & 192 \tabularnewline
3 & 191.8 & 194.025 \tabularnewline
4 & 163.7625 & 193.8025 \tabularnewline
5 & 272.025 & 190.7985 \tabularnewline
6 & 284.575 & 198.92115 \tabularnewline
7 & 301.6635 & 207.486535 \tabularnewline
8 & 287.5375 & 216.9042315 \tabularnewline
9 & 220.4375 & 223.96755835 \tabularnewline
10 & 178.3 & 223.614552515 \tabularnewline
11 & 284.8875 & 219.0830972635 \tabularnewline
12 & 283.9875 & 225.66353753715 \tabularnewline
13 & 238 & 231.495933783435 \tabularnewline
14 & 216.275 & 232.146340405092 \tabularnewline
15 & 162.875 & 230.559206364582 \tabularnewline
16 & 185.95 & 223.790785728124 \tabularnewline
17 & 193.7875 & 220.006707155312 \tabularnewline
18 & 128.3275 & 217.384786439781 \tabularnewline
19 & 83.925 & 208.479057795803 \tabularnewline
20 & 177.15 & 196.023652016222 \tabularnewline
21 & 142.3 & 194.1362868146 \tabularnewline
22 & 120.5375 & 188.95265813314 \tabularnewline
23 & 269.25 & 182.111142319826 \tabularnewline
24 & 167.625 & 190.825028087843 \tabularnewline
25 & 243.275 & 188.505025279059 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75925&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]192[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]212.25[/C][C]192[/C][/ROW]
[ROW][C]3[/C][C]191.8[/C][C]194.025[/C][/ROW]
[ROW][C]4[/C][C]163.7625[/C][C]193.8025[/C][/ROW]
[ROW][C]5[/C][C]272.025[/C][C]190.7985[/C][/ROW]
[ROW][C]6[/C][C]284.575[/C][C]198.92115[/C][/ROW]
[ROW][C]7[/C][C]301.6635[/C][C]207.486535[/C][/ROW]
[ROW][C]8[/C][C]287.5375[/C][C]216.9042315[/C][/ROW]
[ROW][C]9[/C][C]220.4375[/C][C]223.96755835[/C][/ROW]
[ROW][C]10[/C][C]178.3[/C][C]223.614552515[/C][/ROW]
[ROW][C]11[/C][C]284.8875[/C][C]219.0830972635[/C][/ROW]
[ROW][C]12[/C][C]283.9875[/C][C]225.66353753715[/C][/ROW]
[ROW][C]13[/C][C]238[/C][C]231.495933783435[/C][/ROW]
[ROW][C]14[/C][C]216.275[/C][C]232.146340405092[/C][/ROW]
[ROW][C]15[/C][C]162.875[/C][C]230.559206364582[/C][/ROW]
[ROW][C]16[/C][C]185.95[/C][C]223.790785728124[/C][/ROW]
[ROW][C]17[/C][C]193.7875[/C][C]220.006707155312[/C][/ROW]
[ROW][C]18[/C][C]128.3275[/C][C]217.384786439781[/C][/ROW]
[ROW][C]19[/C][C]83.925[/C][C]208.479057795803[/C][/ROW]
[ROW][C]20[/C][C]177.15[/C][C]196.023652016222[/C][/ROW]
[ROW][C]21[/C][C]142.3[/C][C]194.1362868146[/C][/ROW]
[ROW][C]22[/C][C]120.5375[/C][C]188.95265813314[/C][/ROW]
[ROW][C]23[/C][C]269.25[/C][C]182.111142319826[/C][/ROW]
[ROW][C]24[/C][C]167.625[/C][C]190.825028087843[/C][/ROW]
[ROW][C]25[/C][C]243.275[/C][C]188.505025279059[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75925&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75925&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
1192NA
2212.25192
3191.8194.025
4163.7625193.8025
5272.025190.7985
6284.575198.92115
7301.6635207.486535
8287.5375216.9042315
9220.4375223.96755835
10178.3223.614552515
11284.8875219.0830972635
12283.9875225.66353753715
13238231.495933783435
14216.275232.146340405092
15162.875230.559206364582
16185.95223.790785728124
17193.7875220.006707155312
18128.3275217.384786439781
1983.925208.479057795803
20177.15196.023652016222
21142.3194.1362868146
22120.5375188.95265813314
23269.25182.111142319826
24167.625190.825028087843
25243.275188.505025279059







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

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