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:01:58 +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/t1273755755ah2csdpzyxi4pzw.htm/, Retrieved Sun, 05 May 2024 23:36:02 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75915, Retrieved Sun, 05 May 2024 23:36:02 +0000
QR Codes:

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

Post a new message
Dataseries X:
285
215,375
313,725
256,7625
273,79
173,0125
174,875
258,2625
222,65
231,7375
150,778
144,1375
136,15
152,875
238,375
147,8
35,425
80,375
143,375
194,8875
190,43
122,525
153,125
79,6
182,8625




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75915&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
26165.60561479886559.452353951103696.195728341672235.015501256059271.758875646627
27165.60561479886558.922907969224695.8495422217736235.361687375957272.288321628506
28165.60561479886558.396076583344695.5050656943077235.706163903423272.815153014386
29165.60561479886557.87182143637795.1622736789234236.048955918807273.339408161354
30165.60561479886557.350105100016994.8211417025676236.390087895163273.861124497714
31165.60561479886556.830891043557394.4816458790947236.729583718636274.380338554173
32165.60561479886556.314143604038294.1437628897488237.067466707982274.897085993692
33165.60561479886555.799827957661793.807469964472237.403759633258275.411401640069
34165.60561479886555.287910092404193.4727448639978237.738484733733275.923319505326
35165.60561479886554.778356781768793.1395658626875238.071663735043276.432872815962

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
26 & 165.605614798865 & 59.4523539511036 & 96.195728341672 & 235.015501256059 & 271.758875646627 \tabularnewline
27 & 165.605614798865 & 58.9229079692246 & 95.8495422217736 & 235.361687375957 & 272.288321628506 \tabularnewline
28 & 165.605614798865 & 58.3960765833446 & 95.5050656943077 & 235.706163903423 & 272.815153014386 \tabularnewline
29 & 165.605614798865 & 57.871821436377 & 95.1622736789234 & 236.048955918807 & 273.339408161354 \tabularnewline
30 & 165.605614798865 & 57.3501051000169 & 94.8211417025676 & 236.390087895163 & 273.861124497714 \tabularnewline
31 & 165.605614798865 & 56.8308910435573 & 94.4816458790947 & 236.729583718636 & 274.380338554173 \tabularnewline
32 & 165.605614798865 & 56.3141436040382 & 94.1437628897488 & 237.067466707982 & 274.897085993692 \tabularnewline
33 & 165.605614798865 & 55.7998279576617 & 93.807469964472 & 237.403759633258 & 275.411401640069 \tabularnewline
34 & 165.605614798865 & 55.2879100924041 & 93.4727448639978 & 237.738484733733 & 275.923319505326 \tabularnewline
35 & 165.605614798865 & 54.7783567817687 & 93.1395658626875 & 238.071663735043 & 276.432872815962 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75915&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]165.605614798865[/C][C]59.4523539511036[/C][C]96.195728341672[/C][C]235.015501256059[/C][C]271.758875646627[/C][/ROW]
[ROW][C]27[/C][C]165.605614798865[/C][C]58.9229079692246[/C][C]95.8495422217736[/C][C]235.361687375957[/C][C]272.288321628506[/C][/ROW]
[ROW][C]28[/C][C]165.605614798865[/C][C]58.3960765833446[/C][C]95.5050656943077[/C][C]235.706163903423[/C][C]272.815153014386[/C][/ROW]
[ROW][C]29[/C][C]165.605614798865[/C][C]57.871821436377[/C][C]95.1622736789234[/C][C]236.048955918807[/C][C]273.339408161354[/C][/ROW]
[ROW][C]30[/C][C]165.605614798865[/C][C]57.3501051000169[/C][C]94.8211417025676[/C][C]236.390087895163[/C][C]273.861124497714[/C][/ROW]
[ROW][C]31[/C][C]165.605614798865[/C][C]56.8308910435573[/C][C]94.4816458790947[/C][C]236.729583718636[/C][C]274.380338554173[/C][/ROW]
[ROW][C]32[/C][C]165.605614798865[/C][C]56.3141436040382[/C][C]94.1437628897488[/C][C]237.067466707982[/C][C]274.897085993692[/C][/ROW]
[ROW][C]33[/C][C]165.605614798865[/C][C]55.7998279576617[/C][C]93.807469964472[/C][C]237.403759633258[/C][C]275.411401640069[/C][/ROW]
[ROW][C]34[/C][C]165.605614798865[/C][C]55.2879100924041[/C][C]93.4727448639978[/C][C]237.738484733733[/C][C]275.923319505326[/C][/ROW]
[ROW][C]35[/C][C]165.605614798865[/C][C]54.7783567817687[/C][C]93.1395658626875[/C][C]238.071663735043[/C][C]276.432872815962[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75915&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75915&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
26165.60561479886559.452353951103696.195728341672235.015501256059271.758875646627
27165.60561479886558.922907969224695.8495422217736235.361687375957272.288321628506
28165.60561479886558.396076583344695.5050656943077235.706163903423272.815153014386
29165.60561479886557.87182143637795.1622736789234236.048955918807273.339408161354
30165.60561479886557.350105100016994.8211417025676236.390087895163273.861124497714
31165.60561479886556.830891043557394.4816458790947236.729583718636274.380338554173
32165.60561479886556.314143604038294.1437628897488237.067466707982274.897085993692
33165.60561479886555.799827957661793.807469964472237.403759633258275.411401640069
34165.60561479886555.287910092404193.4727448639978237.738484733733275.923319505326
35165.60561479886554.778356781768793.1395658626875238.071663735043276.432872815962







Actuals and Interpolation
TimeActualForecast
1285NA
2215.375285
3313.725278.0375
4256.7625281.60625
5273.79279.121875
6173.0125278.5886875
7174.875268.03106875
8258.2625258.715461875
9222.65258.6701656875
10231.7375255.06814911875
11150.778252.735084206875
12144.1375242.539375786188
13136.15232.699188207569
14152.875223.044269386812
15238.375216.027342448131
16147.8218.262108203318
1735.425211.215897382986
1880.375193.636807644687
19143.375182.310626880219
20194.8875178.417064192197
21190.43180.064107772977
22122.525181.100696995679
23153.125175.243127296111
2479.6173.031314566500
25182.8625163.688183109850

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 285 & NA \tabularnewline
2 & 215.375 & 285 \tabularnewline
3 & 313.725 & 278.0375 \tabularnewline
4 & 256.7625 & 281.60625 \tabularnewline
5 & 273.79 & 279.121875 \tabularnewline
6 & 173.0125 & 278.5886875 \tabularnewline
7 & 174.875 & 268.03106875 \tabularnewline
8 & 258.2625 & 258.715461875 \tabularnewline
9 & 222.65 & 258.6701656875 \tabularnewline
10 & 231.7375 & 255.06814911875 \tabularnewline
11 & 150.778 & 252.735084206875 \tabularnewline
12 & 144.1375 & 242.539375786188 \tabularnewline
13 & 136.15 & 232.699188207569 \tabularnewline
14 & 152.875 & 223.044269386812 \tabularnewline
15 & 238.375 & 216.027342448131 \tabularnewline
16 & 147.8 & 218.262108203318 \tabularnewline
17 & 35.425 & 211.215897382986 \tabularnewline
18 & 80.375 & 193.636807644687 \tabularnewline
19 & 143.375 & 182.310626880219 \tabularnewline
20 & 194.8875 & 178.417064192197 \tabularnewline
21 & 190.43 & 180.064107772977 \tabularnewline
22 & 122.525 & 181.100696995679 \tabularnewline
23 & 153.125 & 175.243127296111 \tabularnewline
24 & 79.6 & 173.031314566500 \tabularnewline
25 & 182.8625 & 163.688183109850 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75915&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]285[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]215.375[/C][C]285[/C][/ROW]
[ROW][C]3[/C][C]313.725[/C][C]278.0375[/C][/ROW]
[ROW][C]4[/C][C]256.7625[/C][C]281.60625[/C][/ROW]
[ROW][C]5[/C][C]273.79[/C][C]279.121875[/C][/ROW]
[ROW][C]6[/C][C]173.0125[/C][C]278.5886875[/C][/ROW]
[ROW][C]7[/C][C]174.875[/C][C]268.03106875[/C][/ROW]
[ROW][C]8[/C][C]258.2625[/C][C]258.715461875[/C][/ROW]
[ROW][C]9[/C][C]222.65[/C][C]258.6701656875[/C][/ROW]
[ROW][C]10[/C][C]231.7375[/C][C]255.06814911875[/C][/ROW]
[ROW][C]11[/C][C]150.778[/C][C]252.735084206875[/C][/ROW]
[ROW][C]12[/C][C]144.1375[/C][C]242.539375786188[/C][/ROW]
[ROW][C]13[/C][C]136.15[/C][C]232.699188207569[/C][/ROW]
[ROW][C]14[/C][C]152.875[/C][C]223.044269386812[/C][/ROW]
[ROW][C]15[/C][C]238.375[/C][C]216.027342448131[/C][/ROW]
[ROW][C]16[/C][C]147.8[/C][C]218.262108203318[/C][/ROW]
[ROW][C]17[/C][C]35.425[/C][C]211.215897382986[/C][/ROW]
[ROW][C]18[/C][C]80.375[/C][C]193.636807644687[/C][/ROW]
[ROW][C]19[/C][C]143.375[/C][C]182.310626880219[/C][/ROW]
[ROW][C]20[/C][C]194.8875[/C][C]178.417064192197[/C][/ROW]
[ROW][C]21[/C][C]190.43[/C][C]180.064107772977[/C][/ROW]
[ROW][C]22[/C][C]122.525[/C][C]181.100696995679[/C][/ROW]
[ROW][C]23[/C][C]153.125[/C][C]175.243127296111[/C][/ROW]
[ROW][C]24[/C][C]79.6[/C][C]173.031314566500[/C][/ROW]
[ROW][C]25[/C][C]182.8625[/C][C]163.688183109850[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75915&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75915&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
1285NA
2215.375285
3313.725278.0375
4256.7625281.60625
5273.79279.121875
6173.0125278.5886875
7174.875268.03106875
8258.2625258.715461875
9222.65258.6701656875
10231.7375255.06814911875
11150.778252.735084206875
12144.1375242.539375786188
13136.15232.699188207569
14152.875223.044269386812
15238.375216.027342448131
16147.8218.262108203318
1735.425211.215897382986
1880.375193.636807644687
19143.375182.310626880219
20194.8875178.417064192197
21190.43180.064107772977
22122.525181.100696995679
23153.125175.243127296111
2479.6173.031314566500
25182.8625163.688183109850







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

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