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:21:24 +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/t1273756921mxoph0mcxwqfffm.htm/, Retrieved Mon, 06 May 2024 10:27:00 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75930, Retrieved Mon, 06 May 2024 10:27:00 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywordsB611,steven,coomans,croston,thesis,per2maand
Estimated Impact120
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 13:21:24] [d41d8cd98f00b204e9800998ecf8427e] [Current]
Feedback Forum

Post a new message
Dataseries X:
22,325
94,125
12,275
7,125
18,925
38,025
28,138
2,386
13,225
26,25
31,975
31,275
34,4875
52,1375
15,675
48,9
16,5
37
54,125
34,4875
44,4875
40,2
52,13
49,575
44,3625




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75930&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
2637.7456845001459-1.1159091688556012.335454210759063.155914789532776.6072781691473
2737.7456845001459-1.3097337810545112.208719108908263.282649891383576.8011027813462
2837.7456845001459-1.5026012171242212.082609870887963.408759129403876.9939702174159
2937.7456845001459-1.6945255191911511.957117315045063.534251685246777.1858945194829
3037.7456845001459-1.885520389364611.832232482051963.659136518239877.3768893896563
3137.7456845001459-2.0755992011526611.707946627441663.783422372850177.5669682014444
3237.7456845001459-2.2647750103902511.584251214462763.90711778582977.756144010682
3337.7456845001459-2.4530605657040811.46113790723664.030231093055777.9444295659958
3437.7456845001459-2.6404683185386711.338598564199764.15277043609278.1318373188304
3537.7456845001459-2.8270104327654311.216625231825764.27474376846678.3183794330571

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
26 & 37.7456845001459 & -1.11590916885560 & 12.3354542107590 & 63.1559147895327 & 76.6072781691473 \tabularnewline
27 & 37.7456845001459 & -1.30973378105451 & 12.2087191089082 & 63.2826498913835 & 76.8011027813462 \tabularnewline
28 & 37.7456845001459 & -1.50260121712422 & 12.0826098708879 & 63.4087591294038 & 76.9939702174159 \tabularnewline
29 & 37.7456845001459 & -1.69452551919115 & 11.9571173150450 & 63.5342516852467 & 77.1858945194829 \tabularnewline
30 & 37.7456845001459 & -1.8855203893646 & 11.8322324820519 & 63.6591365182398 & 77.3768893896563 \tabularnewline
31 & 37.7456845001459 & -2.07559920115266 & 11.7079466274416 & 63.7834223728501 & 77.5669682014444 \tabularnewline
32 & 37.7456845001459 & -2.26477501039025 & 11.5842512144627 & 63.907117785829 & 77.756144010682 \tabularnewline
33 & 37.7456845001459 & -2.45306056570408 & 11.461137907236 & 64.0302310930557 & 77.9444295659958 \tabularnewline
34 & 37.7456845001459 & -2.64046831853867 & 11.3385985641997 & 64.152770436092 & 78.1318373188304 \tabularnewline
35 & 37.7456845001459 & -2.82701043276543 & 11.2166252318257 & 64.274743768466 & 78.3183794330571 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75930&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]37.7456845001459[/C][C]-1.11590916885560[/C][C]12.3354542107590[/C][C]63.1559147895327[/C][C]76.6072781691473[/C][/ROW]
[ROW][C]27[/C][C]37.7456845001459[/C][C]-1.30973378105451[/C][C]12.2087191089082[/C][C]63.2826498913835[/C][C]76.8011027813462[/C][/ROW]
[ROW][C]28[/C][C]37.7456845001459[/C][C]-1.50260121712422[/C][C]12.0826098708879[/C][C]63.4087591294038[/C][C]76.9939702174159[/C][/ROW]
[ROW][C]29[/C][C]37.7456845001459[/C][C]-1.69452551919115[/C][C]11.9571173150450[/C][C]63.5342516852467[/C][C]77.1858945194829[/C][/ROW]
[ROW][C]30[/C][C]37.7456845001459[/C][C]-1.8855203893646[/C][C]11.8322324820519[/C][C]63.6591365182398[/C][C]77.3768893896563[/C][/ROW]
[ROW][C]31[/C][C]37.7456845001459[/C][C]-2.07559920115266[/C][C]11.7079466274416[/C][C]63.7834223728501[/C][C]77.5669682014444[/C][/ROW]
[ROW][C]32[/C][C]37.7456845001459[/C][C]-2.26477501039025[/C][C]11.5842512144627[/C][C]63.907117785829[/C][C]77.756144010682[/C][/ROW]
[ROW][C]33[/C][C]37.7456845001459[/C][C]-2.45306056570408[/C][C]11.461137907236[/C][C]64.0302310930557[/C][C]77.9444295659958[/C][/ROW]
[ROW][C]34[/C][C]37.7456845001459[/C][C]-2.64046831853867[/C][C]11.3385985641997[/C][C]64.152770436092[/C][C]78.1318373188304[/C][/ROW]
[ROW][C]35[/C][C]37.7456845001459[/C][C]-2.82701043276543[/C][C]11.2166252318257[/C][C]64.274743768466[/C][C]78.3183794330571[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75930&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75930&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
2637.7456845001459-1.1159091688556012.335454210759063.155914789532776.6072781691473
2737.7456845001459-1.3097337810545112.208719108908263.282649891383576.8011027813462
2837.7456845001459-1.5026012171242212.082609870887963.408759129403876.9939702174159
2937.7456845001459-1.6945255191911511.957117315045063.534251685246777.1858945194829
3037.7456845001459-1.885520389364611.832232482051963.659136518239877.3768893896563
3137.7456845001459-2.0755992011526611.707946627441663.783422372850177.5669682014444
3237.7456845001459-2.2647750103902511.584251214462763.90711778582977.756144010682
3337.7456845001459-2.4530605657040811.46113790723664.030231093055777.9444295659958
3437.7456845001459-2.6404683185386711.338598564199764.15277043609278.1318373188304
3537.7456845001459-2.8270104327654311.216625231825764.27474376846678.3183794330571







Actuals and Interpolation
TimeActualForecast
122.325NA
294.12522.325
312.27529.505
47.12527.782
518.92525.7163
638.02525.03717
728.13826.335953
82.38626.5161577
913.22524.10314193
1026.2523.015327737
1131.97523.3387949633
1231.27524.20241546697
1334.487524.909673920273
1452.137525.8674565282457
1515.67528.4944608754211
1648.927.2125147878790
1716.529.3812633090911
183728.093136978182
1954.12528.9838232803638
2034.487531.4979409523274
2144.487531.7968968570947
2240.233.0659571713852
2352.1333.7793614542467
2449.57535.614425308822
2544.362537.0104827779398

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 22.325 & NA \tabularnewline
2 & 94.125 & 22.325 \tabularnewline
3 & 12.275 & 29.505 \tabularnewline
4 & 7.125 & 27.782 \tabularnewline
5 & 18.925 & 25.7163 \tabularnewline
6 & 38.025 & 25.03717 \tabularnewline
7 & 28.138 & 26.335953 \tabularnewline
8 & 2.386 & 26.5161577 \tabularnewline
9 & 13.225 & 24.10314193 \tabularnewline
10 & 26.25 & 23.015327737 \tabularnewline
11 & 31.975 & 23.3387949633 \tabularnewline
12 & 31.275 & 24.20241546697 \tabularnewline
13 & 34.4875 & 24.909673920273 \tabularnewline
14 & 52.1375 & 25.8674565282457 \tabularnewline
15 & 15.675 & 28.4944608754211 \tabularnewline
16 & 48.9 & 27.2125147878790 \tabularnewline
17 & 16.5 & 29.3812633090911 \tabularnewline
18 & 37 & 28.093136978182 \tabularnewline
19 & 54.125 & 28.9838232803638 \tabularnewline
20 & 34.4875 & 31.4979409523274 \tabularnewline
21 & 44.4875 & 31.7968968570947 \tabularnewline
22 & 40.2 & 33.0659571713852 \tabularnewline
23 & 52.13 & 33.7793614542467 \tabularnewline
24 & 49.575 & 35.614425308822 \tabularnewline
25 & 44.3625 & 37.0104827779398 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75930&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]22.325[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]94.125[/C][C]22.325[/C][/ROW]
[ROW][C]3[/C][C]12.275[/C][C]29.505[/C][/ROW]
[ROW][C]4[/C][C]7.125[/C][C]27.782[/C][/ROW]
[ROW][C]5[/C][C]18.925[/C][C]25.7163[/C][/ROW]
[ROW][C]6[/C][C]38.025[/C][C]25.03717[/C][/ROW]
[ROW][C]7[/C][C]28.138[/C][C]26.335953[/C][/ROW]
[ROW][C]8[/C][C]2.386[/C][C]26.5161577[/C][/ROW]
[ROW][C]9[/C][C]13.225[/C][C]24.10314193[/C][/ROW]
[ROW][C]10[/C][C]26.25[/C][C]23.015327737[/C][/ROW]
[ROW][C]11[/C][C]31.975[/C][C]23.3387949633[/C][/ROW]
[ROW][C]12[/C][C]31.275[/C][C]24.20241546697[/C][/ROW]
[ROW][C]13[/C][C]34.4875[/C][C]24.909673920273[/C][/ROW]
[ROW][C]14[/C][C]52.1375[/C][C]25.8674565282457[/C][/ROW]
[ROW][C]15[/C][C]15.675[/C][C]28.4944608754211[/C][/ROW]
[ROW][C]16[/C][C]48.9[/C][C]27.2125147878790[/C][/ROW]
[ROW][C]17[/C][C]16.5[/C][C]29.3812633090911[/C][/ROW]
[ROW][C]18[/C][C]37[/C][C]28.093136978182[/C][/ROW]
[ROW][C]19[/C][C]54.125[/C][C]28.9838232803638[/C][/ROW]
[ROW][C]20[/C][C]34.4875[/C][C]31.4979409523274[/C][/ROW]
[ROW][C]21[/C][C]44.4875[/C][C]31.7968968570947[/C][/ROW]
[ROW][C]22[/C][C]40.2[/C][C]33.0659571713852[/C][/ROW]
[ROW][C]23[/C][C]52.13[/C][C]33.7793614542467[/C][/ROW]
[ROW][C]24[/C][C]49.575[/C][C]35.614425308822[/C][/ROW]
[ROW][C]25[/C][C]44.3625[/C][C]37.0104827779398[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75930&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75930&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
122.325NA
294.12522.325
312.27529.505
47.12527.782
518.92525.7163
638.02525.03717
728.13826.335953
82.38626.5161577
913.22524.10314193
1026.2523.015327737
1131.97523.3387949633
1231.27524.20241546697
1334.487524.909673920273
1452.137525.8674565282457
1515.67528.4944608754211
1648.927.2125147878790
1716.529.3812633090911
183728.093136978182
1954.12528.9838232803638
2034.487531.4979409523274
2144.487531.7968968570947
2240.233.0659571713852
2352.1333.7793614542467
2449.57535.614425308822
2544.362537.0104827779398







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

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