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

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

Post a new message
Dataseries X:
250,75
314,5125
449,3885
305,7
162,375
352,025
379,125
327,125
423,6625
152,25
183,8125
153,8875
245,625
108,9
291,625
284,875
192,25
45,2625
205,375
301,25
165,375
281,6375
140,5875
331,75
232,625




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75912&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
26234.12901537049330.6178882034065101.060241819569367.197788921416437.640142537579
27234.12901537049329.6028638161594100.396553046305367.861477694681438.655166924826
28234.12901537049328.592851986930799.7361418085592368.521888932426439.665178754055
29234.12901537049327.587779179647699.0789600236795369.179070717306440.670251561338
30234.12901537049326.587573638845798.4249607732892369.833069967696441.670457102139
31234.12901537049325.592165329885197.7740982641989370.483932476786442.6658654111
32234.12901537049324.601485881723597.1263277909867371.131702949998443.656544859262
33234.12901537049323.615468532111796.4816057001644371.776425040821444.642562208873
34234.12901537049322.634048075090195.8398893558466372.418141385139445.623982665895
35234.12901537049321.657160810667495.2011371068478373.056893634137446.600869930318

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
26 & 234.129015370493 & 30.6178882034065 & 101.060241819569 & 367.197788921416 & 437.640142537579 \tabularnewline
27 & 234.129015370493 & 29.6028638161594 & 100.396553046305 & 367.861477694681 & 438.655166924826 \tabularnewline
28 & 234.129015370493 & 28.5928519869307 & 99.7361418085592 & 368.521888932426 & 439.665178754055 \tabularnewline
29 & 234.129015370493 & 27.5877791796476 & 99.0789600236795 & 369.179070717306 & 440.670251561338 \tabularnewline
30 & 234.129015370493 & 26.5875736388457 & 98.4249607732892 & 369.833069967696 & 441.670457102139 \tabularnewline
31 & 234.129015370493 & 25.5921653298851 & 97.7740982641989 & 370.483932476786 & 442.6658654111 \tabularnewline
32 & 234.129015370493 & 24.6014858817235 & 97.1263277909867 & 371.131702949998 & 443.656544859262 \tabularnewline
33 & 234.129015370493 & 23.6154685321117 & 96.4816057001644 & 371.776425040821 & 444.642562208873 \tabularnewline
34 & 234.129015370493 & 22.6340480750901 & 95.8398893558466 & 372.418141385139 & 445.623982665895 \tabularnewline
35 & 234.129015370493 & 21.6571608106674 & 95.2011371068478 & 373.056893634137 & 446.600869930318 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75912&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]234.129015370493[/C][C]30.6178882034065[/C][C]101.060241819569[/C][C]367.197788921416[/C][C]437.640142537579[/C][/ROW]
[ROW][C]27[/C][C]234.129015370493[/C][C]29.6028638161594[/C][C]100.396553046305[/C][C]367.861477694681[/C][C]438.655166924826[/C][/ROW]
[ROW][C]28[/C][C]234.129015370493[/C][C]28.5928519869307[/C][C]99.7361418085592[/C][C]368.521888932426[/C][C]439.665178754055[/C][/ROW]
[ROW][C]29[/C][C]234.129015370493[/C][C]27.5877791796476[/C][C]99.0789600236795[/C][C]369.179070717306[/C][C]440.670251561338[/C][/ROW]
[ROW][C]30[/C][C]234.129015370493[/C][C]26.5875736388457[/C][C]98.4249607732892[/C][C]369.833069967696[/C][C]441.670457102139[/C][/ROW]
[ROW][C]31[/C][C]234.129015370493[/C][C]25.5921653298851[/C][C]97.7740982641989[/C][C]370.483932476786[/C][C]442.6658654111[/C][/ROW]
[ROW][C]32[/C][C]234.129015370493[/C][C]24.6014858817235[/C][C]97.1263277909867[/C][C]371.131702949998[/C][C]443.656544859262[/C][/ROW]
[ROW][C]33[/C][C]234.129015370493[/C][C]23.6154685321117[/C][C]96.4816057001644[/C][C]371.776425040821[/C][C]444.642562208873[/C][/ROW]
[ROW][C]34[/C][C]234.129015370493[/C][C]22.6340480750901[/C][C]95.8398893558466[/C][C]372.418141385139[/C][C]445.623982665895[/C][/ROW]
[ROW][C]35[/C][C]234.129015370493[/C][C]21.6571608106674[/C][C]95.2011371068478[/C][C]373.056893634137[/C][C]446.600869930318[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75912&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75912&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
26234.12901537049330.6178882034065101.060241819569367.197788921416437.640142537579
27234.12901537049329.6028638161594100.396553046305367.861477694681438.655166924826
28234.12901537049328.592851986930799.7361418085592368.521888932426439.665178754055
29234.12901537049327.587779179647699.0789600236795369.179070717306440.670251561338
30234.12901537049326.587573638845798.4249607732892369.833069967696441.670457102139
31234.12901537049325.592165329885197.7740982641989370.483932476786442.6658654111
32234.12901537049324.601485881723597.1263277909867371.131702949998443.656544859262
33234.12901537049323.615468532111796.4816057001644371.776425040821444.642562208873
34234.12901537049322.634048075090195.8398893558466372.418141385139445.623982665895
35234.12901537049321.657160810667495.2011371068478373.056893634137446.600869930318







Actuals and Interpolation
TimeActualForecast
1250.75NA
2314.5125250.75
3449.3885257.12625
4305.7276.352475
5162.375279.2872275
6352.025267.59600475
7379.125276.038904275
8327.125286.3475138475
9423.6625290.42526246275
10152.25303.748986216475
11183.8125288.599087594828
12153.8875278.120428835345
13245.625265.697135951810
14108.9263.689922356629
15291.625248.210930120966
16284.875252.552337108870
17192.25255.784603397983
1845.2625249.431143058184
19205.375229.014278752366
20301.25226.650350877129
21165.375234.110315789416
22281.6375227.236784210475
23140.5875232.676855789427
24331.75223.467920210485
25232.625234.296128189436

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 250.75 & NA \tabularnewline
2 & 314.5125 & 250.75 \tabularnewline
3 & 449.3885 & 257.12625 \tabularnewline
4 & 305.7 & 276.352475 \tabularnewline
5 & 162.375 & 279.2872275 \tabularnewline
6 & 352.025 & 267.59600475 \tabularnewline
7 & 379.125 & 276.038904275 \tabularnewline
8 & 327.125 & 286.3475138475 \tabularnewline
9 & 423.6625 & 290.42526246275 \tabularnewline
10 & 152.25 & 303.748986216475 \tabularnewline
11 & 183.8125 & 288.599087594828 \tabularnewline
12 & 153.8875 & 278.120428835345 \tabularnewline
13 & 245.625 & 265.697135951810 \tabularnewline
14 & 108.9 & 263.689922356629 \tabularnewline
15 & 291.625 & 248.210930120966 \tabularnewline
16 & 284.875 & 252.552337108870 \tabularnewline
17 & 192.25 & 255.784603397983 \tabularnewline
18 & 45.2625 & 249.431143058184 \tabularnewline
19 & 205.375 & 229.014278752366 \tabularnewline
20 & 301.25 & 226.650350877129 \tabularnewline
21 & 165.375 & 234.110315789416 \tabularnewline
22 & 281.6375 & 227.236784210475 \tabularnewline
23 & 140.5875 & 232.676855789427 \tabularnewline
24 & 331.75 & 223.467920210485 \tabularnewline
25 & 232.625 & 234.296128189436 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75912&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]250.75[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]314.5125[/C][C]250.75[/C][/ROW]
[ROW][C]3[/C][C]449.3885[/C][C]257.12625[/C][/ROW]
[ROW][C]4[/C][C]305.7[/C][C]276.352475[/C][/ROW]
[ROW][C]5[/C][C]162.375[/C][C]279.2872275[/C][/ROW]
[ROW][C]6[/C][C]352.025[/C][C]267.59600475[/C][/ROW]
[ROW][C]7[/C][C]379.125[/C][C]276.038904275[/C][/ROW]
[ROW][C]8[/C][C]327.125[/C][C]286.3475138475[/C][/ROW]
[ROW][C]9[/C][C]423.6625[/C][C]290.42526246275[/C][/ROW]
[ROW][C]10[/C][C]152.25[/C][C]303.748986216475[/C][/ROW]
[ROW][C]11[/C][C]183.8125[/C][C]288.599087594828[/C][/ROW]
[ROW][C]12[/C][C]153.8875[/C][C]278.120428835345[/C][/ROW]
[ROW][C]13[/C][C]245.625[/C][C]265.697135951810[/C][/ROW]
[ROW][C]14[/C][C]108.9[/C][C]263.689922356629[/C][/ROW]
[ROW][C]15[/C][C]291.625[/C][C]248.210930120966[/C][/ROW]
[ROW][C]16[/C][C]284.875[/C][C]252.552337108870[/C][/ROW]
[ROW][C]17[/C][C]192.25[/C][C]255.784603397983[/C][/ROW]
[ROW][C]18[/C][C]45.2625[/C][C]249.431143058184[/C][/ROW]
[ROW][C]19[/C][C]205.375[/C][C]229.014278752366[/C][/ROW]
[ROW][C]20[/C][C]301.25[/C][C]226.650350877129[/C][/ROW]
[ROW][C]21[/C][C]165.375[/C][C]234.110315789416[/C][/ROW]
[ROW][C]22[/C][C]281.6375[/C][C]227.236784210475[/C][/ROW]
[ROW][C]23[/C][C]140.5875[/C][C]232.676855789427[/C][/ROW]
[ROW][C]24[/C][C]331.75[/C][C]223.467920210485[/C][/ROW]
[ROW][C]25[/C][C]232.625[/C][C]234.296128189436[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75912&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75912&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
1250.75NA
2314.5125250.75
3449.3885257.12625
4305.7276.352475
5162.375279.2872275
6352.025267.59600475
7379.125276.038904275
8327.125286.3475138475
9423.6625290.42526246275
10152.25303.748986216475
11183.8125288.599087594828
12153.8875278.120428835345
13245.625265.697135951810
14108.9263.689922356629
15291.625248.210930120966
16284.875252.552337108870
17192.25255.784603397983
1845.2625249.431143058184
19205.375229.014278752366
20301.25226.650350877129
21165.375234.110315789416
22281.6375227.236784210475
23140.5875232.676855789427
24331.75223.467920210485
25232.625234.296128189436







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

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