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:50:16 +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/t1273758654jhql7sphssvw9jk.htm/, Retrieved Mon, 06 May 2024 08:27:12 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75939, Retrieved Mon, 06 May 2024 08:27:12 +0000
QR Codes:

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

Post a new message
Dataseries X:
41
31,66666667
23,83333333
12,33333333
30,83333333
20,83333333
25,50166667
5,166666667
11,66666667
0,833333333
2,341666667
0
0,666666667
8,666666667
2,333333333
11,66666667
0,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=75939&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=75939&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75939&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
1815.70711313335060.8476240187793485.9910154457491625.423210820952130.5666022479219
1915.70711313335060.7735113938665125.9425558050451225.471670461656130.6407148728348
2015.70711313335060.6997647639356085.8943354755966925.519890791104630.7144615027657
2115.70711313335060.6263787597054165.8463509466195725.567875320081730.7878475069959
2215.70711313335060.5533481419069215.7985987923399125.615627474361430.8608781247944
2315.70711313335060.4806677969181765.7510756691400125.663150597561330.9335584697831
2415.70711313335060.4083327325857985.7037783128262525.710447953875031.0058935341155
2515.70711313335060.3363380742234295.6567035360125425.757522730688731.0778881924778
2615.70711313335060.264679060778155.6098482256136925.804378041087631.1495472059231
2715.70711313335060.1933510411562285.5632093404429925.851016926258331.2208752255450

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
18 & 15.7071131333506 & 0.847624018779348 & 5.99101544574916 & 25.4232108209521 & 30.5666022479219 \tabularnewline
19 & 15.7071131333506 & 0.773511393866512 & 5.94255580504512 & 25.4716704616561 & 30.6407148728348 \tabularnewline
20 & 15.7071131333506 & 0.699764763935608 & 5.89433547559669 & 25.5198907911046 & 30.7144615027657 \tabularnewline
21 & 15.7071131333506 & 0.626378759705416 & 5.84635094661957 & 25.5678753200817 & 30.7878475069959 \tabularnewline
22 & 15.7071131333506 & 0.553348141906921 & 5.79859879233991 & 25.6156274743614 & 30.8608781247944 \tabularnewline
23 & 15.7071131333506 & 0.480667796918176 & 5.75107566914001 & 25.6631505975613 & 30.9335584697831 \tabularnewline
24 & 15.7071131333506 & 0.408332732585798 & 5.70377831282625 & 25.7104479538750 & 31.0058935341155 \tabularnewline
25 & 15.7071131333506 & 0.336338074223429 & 5.65670353601254 & 25.7575227306887 & 31.0778881924778 \tabularnewline
26 & 15.7071131333506 & 0.26467906077815 & 5.60984822561369 & 25.8043780410876 & 31.1495472059231 \tabularnewline
27 & 15.7071131333506 & 0.193351041156228 & 5.56320934044299 & 25.8510169262583 & 31.2208752255450 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75939&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]15.7071131333506[/C][C]0.847624018779348[/C][C]5.99101544574916[/C][C]25.4232108209521[/C][C]30.5666022479219[/C][/ROW]
[ROW][C]19[/C][C]15.7071131333506[/C][C]0.773511393866512[/C][C]5.94255580504512[/C][C]25.4716704616561[/C][C]30.6407148728348[/C][/ROW]
[ROW][C]20[/C][C]15.7071131333506[/C][C]0.699764763935608[/C][C]5.89433547559669[/C][C]25.5198907911046[/C][C]30.7144615027657[/C][/ROW]
[ROW][C]21[/C][C]15.7071131333506[/C][C]0.626378759705416[/C][C]5.84635094661957[/C][C]25.5678753200817[/C][C]30.7878475069959[/C][/ROW]
[ROW][C]22[/C][C]15.7071131333506[/C][C]0.553348141906921[/C][C]5.79859879233991[/C][C]25.6156274743614[/C][C]30.8608781247944[/C][/ROW]
[ROW][C]23[/C][C]15.7071131333506[/C][C]0.480667796918176[/C][C]5.75107566914001[/C][C]25.6631505975613[/C][C]30.9335584697831[/C][/ROW]
[ROW][C]24[/C][C]15.7071131333506[/C][C]0.408332732585798[/C][C]5.70377831282625[/C][C]25.7104479538750[/C][C]31.0058935341155[/C][/ROW]
[ROW][C]25[/C][C]15.7071131333506[/C][C]0.336338074223429[/C][C]5.65670353601254[/C][C]25.7575227306887[/C][C]31.0778881924778[/C][/ROW]
[ROW][C]26[/C][C]15.7071131333506[/C][C]0.26467906077815[/C][C]5.60984822561369[/C][C]25.8043780410876[/C][C]31.1495472059231[/C][/ROW]
[ROW][C]27[/C][C]15.7071131333506[/C][C]0.193351041156228[/C][C]5.56320934044299[/C][C]25.8510169262583[/C][C]31.2208752255450[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75939&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75939&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
1815.70711313335060.8476240187793485.9910154457491625.423210820952130.5666022479219
1915.70711313335060.7735113938665125.9425558050451225.471670461656130.6407148728348
2015.70711313335060.6997647639356085.8943354755966925.519890791104630.7144615027657
2115.70711313335060.6263787597054165.8463509466195725.567875320081730.7878475069959
2215.70711313335060.5533481419069215.7985987923399125.615627474361430.8608781247944
2315.70711313335060.4806677969181765.7510756691400125.663150597561330.9335584697831
2415.70711313335060.4083327325857985.7037783128262525.710447953875031.0058935341155
2515.70711313335060.3363380742234295.6567035360125425.757522730688731.0778881924778
2615.70711313335060.264679060778155.6098482256136925.804378041087631.1495472059231
2715.70711313335060.1933510411562285.5632093404429925.851016926258331.2208752255450







Actuals and Interpolation
TimeActualForecast
141NA
231.6666666741
323.8333333340.066666667
412.3333333338.4433333333
530.8333333335.83233333297
620.8333333335.332433332673
725.5016666733.8825233324057
85.16666666733.0444376661651
911.6666666730.2566605662486
100.83333333328.3976611766238
112.34166666725.6412283922614
12023.3112722197352
130.66666666723.3112722197352
148.66666666719.1334651495107
152.33333333318.1732084079959
1611.6666666716.7079100661832
170.27516.2380393050513

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 41 & NA \tabularnewline
2 & 31.66666667 & 41 \tabularnewline
3 & 23.83333333 & 40.066666667 \tabularnewline
4 & 12.33333333 & 38.4433333333 \tabularnewline
5 & 30.83333333 & 35.83233333297 \tabularnewline
6 & 20.83333333 & 35.332433332673 \tabularnewline
7 & 25.50166667 & 33.8825233324057 \tabularnewline
8 & 5.166666667 & 33.0444376661651 \tabularnewline
9 & 11.66666667 & 30.2566605662486 \tabularnewline
10 & 0.833333333 & 28.3976611766238 \tabularnewline
11 & 2.341666667 & 25.6412283922614 \tabularnewline
12 & 0 & 23.3112722197352 \tabularnewline
13 & 0.666666667 & 23.3112722197352 \tabularnewline
14 & 8.666666667 & 19.1334651495107 \tabularnewline
15 & 2.333333333 & 18.1732084079959 \tabularnewline
16 & 11.66666667 & 16.7079100661832 \tabularnewline
17 & 0.275 & 16.2380393050513 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75939&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]41[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]31.66666667[/C][C]41[/C][/ROW]
[ROW][C]3[/C][C]23.83333333[/C][C]40.066666667[/C][/ROW]
[ROW][C]4[/C][C]12.33333333[/C][C]38.4433333333[/C][/ROW]
[ROW][C]5[/C][C]30.83333333[/C][C]35.83233333297[/C][/ROW]
[ROW][C]6[/C][C]20.83333333[/C][C]35.332433332673[/C][/ROW]
[ROW][C]7[/C][C]25.50166667[/C][C]33.8825233324057[/C][/ROW]
[ROW][C]8[/C][C]5.166666667[/C][C]33.0444376661651[/C][/ROW]
[ROW][C]9[/C][C]11.66666667[/C][C]30.2566605662486[/C][/ROW]
[ROW][C]10[/C][C]0.833333333[/C][C]28.3976611766238[/C][/ROW]
[ROW][C]11[/C][C]2.341666667[/C][C]25.6412283922614[/C][/ROW]
[ROW][C]12[/C][C]0[/C][C]23.3112722197352[/C][/ROW]
[ROW][C]13[/C][C]0.666666667[/C][C]23.3112722197352[/C][/ROW]
[ROW][C]14[/C][C]8.666666667[/C][C]19.1334651495107[/C][/ROW]
[ROW][C]15[/C][C]2.333333333[/C][C]18.1732084079959[/C][/ROW]
[ROW][C]16[/C][C]11.66666667[/C][C]16.7079100661832[/C][/ROW]
[ROW][C]17[/C][C]0.275[/C][C]16.2380393050513[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75939&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75939&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
141NA
231.6666666741
323.8333333340.066666667
412.3333333338.4433333333
530.8333333335.83233333297
620.8333333335.332433332673
725.5016666733.8825233324057
85.16666666733.0444376661651
911.6666666730.2566605662486
100.83333333328.3976611766238
112.34166666725.6412283922614
12023.3112722197352
130.66666666723.3112722197352
148.66666666719.1334651495107
152.33333333318.1732084079959
1611.6666666716.7079100661832
170.27516.2380393050513







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

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