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 14:20:22 +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/t1273760452noql40o9sllrxlr.htm/, Retrieved Mon, 06 May 2024 03:52:15 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75963, Retrieved Mon, 06 May 2024 03:52:15 +0000
QR Codes:

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

Post a new message
Dataseries X:
1206,771667
1513,683333
1894,13
1514,458333
1788,191667
1951,223333
1727,026667
1552,248333
1569,528333
2203,916667
2402,373333
1611,8
1324,156667
1852,461667
2412,903333
1664
958,0283333




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time4 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 & 4 seconds \tabularnewline
R Server & wessa.org @ wessa.org \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75963&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]4 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]wessa.org @ wessa.org[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75963&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75963&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 time4 seconds
R Serverwessa.org @ wessa.org







Demand Forecast
PointForecast95% LB80% LB80% UB95% UB
181627.45321263107794.8002039663071083.010674285062171.895750977072460.10622129582
191627.45321263107790.6472953677741080.295233308592174.611191953542464.25912989436
201627.45321263107786.5148953358891077.593202163082177.313223099052468.39152992624
211627.45321263107782.4027030024231074.904384121352180.002041140782472.50372225971
221627.45321263107778.3104247843961072.228587219812182.677838042322476.59600047773
231627.45321263107774.2377741394741069.565624098502185.340801163632480.66865112266
241627.45321263107770.1844713318261066.915311848002187.991113414132484.72195393030
251627.45321263107766.1502432078971064.277471862802190.628953399332488.75618205423
261627.45321263107762.1348229815951061.651929700832193.254495561302492.77160228053
271627.45321263107758.1379500284031059.038514948902195.867910313232496.76847523373

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
18 & 1627.45321263107 & 794.800203966307 & 1083.01067428506 & 2171.89575097707 & 2460.10622129582 \tabularnewline
19 & 1627.45321263107 & 790.647295367774 & 1080.29523330859 & 2174.61119195354 & 2464.25912989436 \tabularnewline
20 & 1627.45321263107 & 786.514895335889 & 1077.59320216308 & 2177.31322309905 & 2468.39152992624 \tabularnewline
21 & 1627.45321263107 & 782.402703002423 & 1074.90438412135 & 2180.00204114078 & 2472.50372225971 \tabularnewline
22 & 1627.45321263107 & 778.310424784396 & 1072.22858721981 & 2182.67783804232 & 2476.59600047773 \tabularnewline
23 & 1627.45321263107 & 774.237774139474 & 1069.56562409850 & 2185.34080116363 & 2480.66865112266 \tabularnewline
24 & 1627.45321263107 & 770.184471331826 & 1066.91531184800 & 2187.99111341413 & 2484.72195393030 \tabularnewline
25 & 1627.45321263107 & 766.150243207897 & 1064.27747186280 & 2190.62895339933 & 2488.75618205423 \tabularnewline
26 & 1627.45321263107 & 762.134822981595 & 1061.65192970083 & 2193.25449556130 & 2492.77160228053 \tabularnewline
27 & 1627.45321263107 & 758.137950028403 & 1059.03851494890 & 2195.86791031323 & 2496.76847523373 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75963&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]1627.45321263107[/C][C]794.800203966307[/C][C]1083.01067428506[/C][C]2171.89575097707[/C][C]2460.10622129582[/C][/ROW]
[ROW][C]19[/C][C]1627.45321263107[/C][C]790.647295367774[/C][C]1080.29523330859[/C][C]2174.61119195354[/C][C]2464.25912989436[/C][/ROW]
[ROW][C]20[/C][C]1627.45321263107[/C][C]786.514895335889[/C][C]1077.59320216308[/C][C]2177.31322309905[/C][C]2468.39152992624[/C][/ROW]
[ROW][C]21[/C][C]1627.45321263107[/C][C]782.402703002423[/C][C]1074.90438412135[/C][C]2180.00204114078[/C][C]2472.50372225971[/C][/ROW]
[ROW][C]22[/C][C]1627.45321263107[/C][C]778.310424784396[/C][C]1072.22858721981[/C][C]2182.67783804232[/C][C]2476.59600047773[/C][/ROW]
[ROW][C]23[/C][C]1627.45321263107[/C][C]774.237774139474[/C][C]1069.56562409850[/C][C]2185.34080116363[/C][C]2480.66865112266[/C][/ROW]
[ROW][C]24[/C][C]1627.45321263107[/C][C]770.184471331826[/C][C]1066.91531184800[/C][C]2187.99111341413[/C][C]2484.72195393030[/C][/ROW]
[ROW][C]25[/C][C]1627.45321263107[/C][C]766.150243207897[/C][C]1064.27747186280[/C][C]2190.62895339933[/C][C]2488.75618205423[/C][/ROW]
[ROW][C]26[/C][C]1627.45321263107[/C][C]762.134822981595[/C][C]1061.65192970083[/C][C]2193.25449556130[/C][C]2492.77160228053[/C][/ROW]
[ROW][C]27[/C][C]1627.45321263107[/C][C]758.137950028403[/C][C]1059.03851494890[/C][C]2195.86791031323[/C][C]2496.76847523373[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75963&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75963&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
181627.45321263107794.8002039663071083.010674285062171.895750977072460.10622129582
191627.45321263107790.6472953677741080.295233308592174.611191953542464.25912989436
201627.45321263107786.5148953358891077.593202163082177.313223099052468.39152992624
211627.45321263107782.4027030024231074.904384121352180.002041140782472.50372225971
221627.45321263107778.3104247843961072.228587219812182.677838042322476.59600047773
231627.45321263107774.2377741394741069.565624098502185.340801163632480.66865112266
241627.45321263107770.1844713318261066.915311848002187.991113414132484.72195393030
251627.45321263107766.1502432078971064.277471862802190.628953399332488.75618205423
261627.45321263107762.1348229815951061.651929700832193.254495561302492.77160228053
271627.45321263107758.1379500284031059.038514948902195.867910313232496.76847523373







Actuals and Interpolation
TimeActualForecast
11206.771667NA
21513.6833331206.771667
31894.131237.4628336
41514.4583331303.12955024
51788.1916671324.262428516
61951.2233331370.6553523644
71727.0266671428.71215042796
81552.2483331458.54360208516
91569.5283331467.91407517665
102203.9166671478.07550095898
112402.3733331550.65961756309
121611.81635.83098910678
131324.1566671633.4278901961
141852.4616671602.50076787649
152412.9033331627.49685778884
1616641706.03750530996
17958.02833331701.83375477896

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 1206.771667 & NA \tabularnewline
2 & 1513.683333 & 1206.771667 \tabularnewline
3 & 1894.13 & 1237.4628336 \tabularnewline
4 & 1514.458333 & 1303.12955024 \tabularnewline
5 & 1788.191667 & 1324.262428516 \tabularnewline
6 & 1951.223333 & 1370.6553523644 \tabularnewline
7 & 1727.026667 & 1428.71215042796 \tabularnewline
8 & 1552.248333 & 1458.54360208516 \tabularnewline
9 & 1569.528333 & 1467.91407517665 \tabularnewline
10 & 2203.916667 & 1478.07550095898 \tabularnewline
11 & 2402.373333 & 1550.65961756309 \tabularnewline
12 & 1611.8 & 1635.83098910678 \tabularnewline
13 & 1324.156667 & 1633.4278901961 \tabularnewline
14 & 1852.461667 & 1602.50076787649 \tabularnewline
15 & 2412.903333 & 1627.49685778884 \tabularnewline
16 & 1664 & 1706.03750530996 \tabularnewline
17 & 958.0283333 & 1701.83375477896 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75963&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]1206.771667[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]1513.683333[/C][C]1206.771667[/C][/ROW]
[ROW][C]3[/C][C]1894.13[/C][C]1237.4628336[/C][/ROW]
[ROW][C]4[/C][C]1514.458333[/C][C]1303.12955024[/C][/ROW]
[ROW][C]5[/C][C]1788.191667[/C][C]1324.262428516[/C][/ROW]
[ROW][C]6[/C][C]1951.223333[/C][C]1370.6553523644[/C][/ROW]
[ROW][C]7[/C][C]1727.026667[/C][C]1428.71215042796[/C][/ROW]
[ROW][C]8[/C][C]1552.248333[/C][C]1458.54360208516[/C][/ROW]
[ROW][C]9[/C][C]1569.528333[/C][C]1467.91407517665[/C][/ROW]
[ROW][C]10[/C][C]2203.916667[/C][C]1478.07550095898[/C][/ROW]
[ROW][C]11[/C][C]2402.373333[/C][C]1550.65961756309[/C][/ROW]
[ROW][C]12[/C][C]1611.8[/C][C]1635.83098910678[/C][/ROW]
[ROW][C]13[/C][C]1324.156667[/C][C]1633.4278901961[/C][/ROW]
[ROW][C]14[/C][C]1852.461667[/C][C]1602.50076787649[/C][/ROW]
[ROW][C]15[/C][C]2412.903333[/C][C]1627.49685778884[/C][/ROW]
[ROW][C]16[/C][C]1664[/C][C]1706.03750530996[/C][/ROW]
[ROW][C]17[/C][C]958.0283333[/C][C]1701.83375477896[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75963&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75963&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
11206.771667NA
21513.6833331206.771667
31894.131237.4628336
41514.4583331303.12955024
51788.1916671324.262428516
61951.2233331370.6553523644
71727.0266671428.71215042796
81552.2483331458.54360208516
91569.5283331467.91407517665
102203.9166671478.07550095898
112402.3733331550.65961756309
121611.81635.83098910678
131324.1566671633.4278901961
141852.4616671602.50076787649
152412.9033331627.49685778884
1616641706.03750530996
17958.02833331701.83375477896







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

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