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:56:43 +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/t127375903880nlpnrxg96aj0r.htm/, Retrieved Mon, 06 May 2024 09:30:22 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75944, Retrieved Mon, 06 May 2024 09:30:22 +0000
QR Codes:

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

Post a new message
Dataseries X:
275.0916667
401.3423333
260.6333333
286.1
368.0833333
385.1916667
181.5333333
145.1
203.1833333
227.5833333
239.0833333
109.175
231.0833333
216.9166667
229.8583333
272.7916667
155.0833333




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75944&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
18235.34455769989876.0785823273295131.206133888707339.482981511089394.610533072466
19235.34455769989875.2842333828162130.686737031693340.002378368102395.404882016979
20235.34455769989874.4938072210671130.169905144461340.519210255334396.195308178728
21235.34455769989873.7072462934133129.655600597958341.033514801837396.981869106382
22235.34455769989872.924494444675129.143786674286341.545328725509397.76462095512
23235.34455769989872.1454968663736128.634427536107342.054687863688398.543618533422
24235.34455769989871.370200051947128.12748819736342.561627202435399.318915347848
25235.34455769989870.5985517538602127.622934495219343.066180904576400.090563645935
26235.34455769989869.8305009425166127.120733063224343.568382336572400.858614457279
27235.34455769989869.0659977668764126.620851305531344.068264094264401.623117632919

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
18 & 235.344557699898 & 76.0785823273295 & 131.206133888707 & 339.482981511089 & 394.610533072466 \tabularnewline
19 & 235.344557699898 & 75.2842333828162 & 130.686737031693 & 340.002378368102 & 395.404882016979 \tabularnewline
20 & 235.344557699898 & 74.4938072210671 & 130.169905144461 & 340.519210255334 & 396.195308178728 \tabularnewline
21 & 235.344557699898 & 73.7072462934133 & 129.655600597958 & 341.033514801837 & 396.981869106382 \tabularnewline
22 & 235.344557699898 & 72.924494444675 & 129.143786674286 & 341.545328725509 & 397.76462095512 \tabularnewline
23 & 235.344557699898 & 72.1454968663736 & 128.634427536107 & 342.054687863688 & 398.543618533422 \tabularnewline
24 & 235.344557699898 & 71.370200051947 & 128.12748819736 & 342.561627202435 & 399.318915347848 \tabularnewline
25 & 235.344557699898 & 70.5985517538602 & 127.622934495219 & 343.066180904576 & 400.090563645935 \tabularnewline
26 & 235.344557699898 & 69.8305009425166 & 127.120733063224 & 343.568382336572 & 400.858614457279 \tabularnewline
27 & 235.344557699898 & 69.0659977668764 & 126.620851305531 & 344.068264094264 & 401.623117632919 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75944&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]235.344557699898[/C][C]76.0785823273295[/C][C]131.206133888707[/C][C]339.482981511089[/C][C]394.610533072466[/C][/ROW]
[ROW][C]19[/C][C]235.344557699898[/C][C]75.2842333828162[/C][C]130.686737031693[/C][C]340.002378368102[/C][C]395.404882016979[/C][/ROW]
[ROW][C]20[/C][C]235.344557699898[/C][C]74.4938072210671[/C][C]130.169905144461[/C][C]340.519210255334[/C][C]396.195308178728[/C][/ROW]
[ROW][C]21[/C][C]235.344557699898[/C][C]73.7072462934133[/C][C]129.655600597958[/C][C]341.033514801837[/C][C]396.981869106382[/C][/ROW]
[ROW][C]22[/C][C]235.344557699898[/C][C]72.924494444675[/C][C]129.143786674286[/C][C]341.545328725509[/C][C]397.76462095512[/C][/ROW]
[ROW][C]23[/C][C]235.344557699898[/C][C]72.1454968663736[/C][C]128.634427536107[/C][C]342.054687863688[/C][C]398.543618533422[/C][/ROW]
[ROW][C]24[/C][C]235.344557699898[/C][C]71.370200051947[/C][C]128.12748819736[/C][C]342.561627202435[/C][C]399.318915347848[/C][/ROW]
[ROW][C]25[/C][C]235.344557699898[/C][C]70.5985517538602[/C][C]127.622934495219[/C][C]343.066180904576[/C][C]400.090563645935[/C][/ROW]
[ROW][C]26[/C][C]235.344557699898[/C][C]69.8305009425166[/C][C]127.120733063224[/C][C]343.568382336572[/C][C]400.858614457279[/C][/ROW]
[ROW][C]27[/C][C]235.344557699898[/C][C]69.0659977668764[/C][C]126.620851305531[/C][C]344.068264094264[/C][C]401.623117632919[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75944&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75944&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
18235.34455769989876.0785823273295131.206133888707339.482981511089394.610533072466
19235.34455769989875.2842333828162130.686737031693340.002378368102395.404882016979
20235.34455769989874.4938072210671130.169905144461340.519210255334396.195308178728
21235.34455769989873.7072462934133129.655600597958341.033514801837396.981869106382
22235.34455769989872.924494444675129.143786674286341.545328725509397.76462095512
23235.34455769989872.1454968663736128.634427536107342.054687863688398.543618533422
24235.34455769989871.370200051947128.12748819736342.561627202435399.318915347848
25235.34455769989870.5985517538602127.622934495219343.066180904576400.090563645935
26235.34455769989869.8305009425166127.120733063224343.568382336572400.858614457279
27235.34455769989869.0659977668764126.620851305531344.068264094264401.623117632919







Actuals and Interpolation
TimeActualForecast
1275.0916667NA
2401.3423333275.0916667
3260.6333333287.71673336
4286.1285.008393354
5368.0833333285.1175540186
6385.1916667293.41413194674
7181.5333333302.591885422066
8145.1290.486030209860
9203.1833333275.947427188874
10227.5833333268.671017799986
11239.0833333264.562249349988
12109.175262.014357744989
13231.0833333246.73042197049
14216.9166667245.165713103441
15229.8583333242.340808463097
16272.7916667241.092560946787
17155.0833333244.262471522108

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 275.0916667 & NA \tabularnewline
2 & 401.3423333 & 275.0916667 \tabularnewline
3 & 260.6333333 & 287.71673336 \tabularnewline
4 & 286.1 & 285.008393354 \tabularnewline
5 & 368.0833333 & 285.1175540186 \tabularnewline
6 & 385.1916667 & 293.41413194674 \tabularnewline
7 & 181.5333333 & 302.591885422066 \tabularnewline
8 & 145.1 & 290.486030209860 \tabularnewline
9 & 203.1833333 & 275.947427188874 \tabularnewline
10 & 227.5833333 & 268.671017799986 \tabularnewline
11 & 239.0833333 & 264.562249349988 \tabularnewline
12 & 109.175 & 262.014357744989 \tabularnewline
13 & 231.0833333 & 246.73042197049 \tabularnewline
14 & 216.9166667 & 245.165713103441 \tabularnewline
15 & 229.8583333 & 242.340808463097 \tabularnewline
16 & 272.7916667 & 241.092560946787 \tabularnewline
17 & 155.0833333 & 244.262471522108 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75944&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]275.0916667[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]401.3423333[/C][C]275.0916667[/C][/ROW]
[ROW][C]3[/C][C]260.6333333[/C][C]287.71673336[/C][/ROW]
[ROW][C]4[/C][C]286.1[/C][C]285.008393354[/C][/ROW]
[ROW][C]5[/C][C]368.0833333[/C][C]285.1175540186[/C][/ROW]
[ROW][C]6[/C][C]385.1916667[/C][C]293.41413194674[/C][/ROW]
[ROW][C]7[/C][C]181.5333333[/C][C]302.591885422066[/C][/ROW]
[ROW][C]8[/C][C]145.1[/C][C]290.486030209860[/C][/ROW]
[ROW][C]9[/C][C]203.1833333[/C][C]275.947427188874[/C][/ROW]
[ROW][C]10[/C][C]227.5833333[/C][C]268.671017799986[/C][/ROW]
[ROW][C]11[/C][C]239.0833333[/C][C]264.562249349988[/C][/ROW]
[ROW][C]12[/C][C]109.175[/C][C]262.014357744989[/C][/ROW]
[ROW][C]13[/C][C]231.0833333[/C][C]246.73042197049[/C][/ROW]
[ROW][C]14[/C][C]216.9166667[/C][C]245.165713103441[/C][/ROW]
[ROW][C]15[/C][C]229.8583333[/C][C]242.340808463097[/C][/ROW]
[ROW][C]16[/C][C]272.7916667[/C][C]241.092560946787[/C][/ROW]
[ROW][C]17[/C][C]155.0833333[/C][C]244.262471522108[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75944&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75944&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
1275.0916667NA
2401.3423333275.0916667
3260.6333333287.71673336
4286.1285.008393354
5368.0833333285.1175540186
6385.1916667293.41413194674
7181.5333333302.591885422066
8145.1290.486030209860
9203.1833333275.947427188874
10227.5833333268.671017799986
11239.0833333264.562249349988
12109.175262.014357744989
13231.0833333246.73042197049
14216.9166667245.165713103441
15229.8583333242.340808463097
16272.7916667241.092560946787
17155.0833333244.262471522108







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

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