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:02:06 +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/t1273759393tfgqa3lteu46f8s.htm/, Retrieved Tue, 07 May 2024 11:21:25 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=75948, Retrieved Tue, 07 May 2024 11:21:25 +0000
QR Codes:

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

Post a new message
Dataseries X:
66
58,66666667
66
51,33333333
73,16666667
65,83333333
65,16666667
80
88
86
94,67433333
66,16666667
94,83333333
72,33333333
86,33333333
64,33333333
62,66666667




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

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75948&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
1873.141172453621647.49804069345956.374029836756289.90831507048798.7843042137841
1973.141172453621647.370143981056756.290402671512389.991942235730898.9122009261864
2073.141172453621647.242878868938456.207188487496290.075156419746999.0394660383047
2173.141172453621647.116236091295356.124381226121290.157963681121999.1661088159478
2273.141172453621646.990206606681656.041974975503690.240369931739599.2921383005615
2373.141172453621646.864781590481555.959963965537390.322380941705899.4175633167616
2473.141172453621646.739952427698555.878342563178990.404002344064399.5423924795446
2573.141172453621646.615710706049855.797105267932390.485239639310999.6666342011933
2673.141172453621646.492048209350755.71624670752390.566098199720199.7902966978924
2773.141172453621646.368956911174055.635761633752590.646583273490799.9133879960692

\begin{tabular}{lllllllll}
\hline
Demand Forecast \tabularnewline
Point & Forecast & 95% LB & 80% LB & 80% UB & 95% UB \tabularnewline
18 & 73.1411724536216 & 47.498040693459 & 56.3740298367562 & 89.908315070487 & 98.7843042137841 \tabularnewline
19 & 73.1411724536216 & 47.3701439810567 & 56.2904026715123 & 89.9919422357308 & 98.9122009261864 \tabularnewline
20 & 73.1411724536216 & 47.2428788689384 & 56.2071884874962 & 90.0751564197469 & 99.0394660383047 \tabularnewline
21 & 73.1411724536216 & 47.1162360912953 & 56.1243812261212 & 90.1579636811219 & 99.1661088159478 \tabularnewline
22 & 73.1411724536216 & 46.9902066066816 & 56.0419749755036 & 90.2403699317395 & 99.2921383005615 \tabularnewline
23 & 73.1411724536216 & 46.8647815904815 & 55.9599639655373 & 90.3223809417058 & 99.4175633167616 \tabularnewline
24 & 73.1411724536216 & 46.7399524276985 & 55.8783425631789 & 90.4040023440643 & 99.5423924795446 \tabularnewline
25 & 73.1411724536216 & 46.6157107060498 & 55.7971052679323 & 90.4852396393109 & 99.6666342011933 \tabularnewline
26 & 73.1411724536216 & 46.4920482093507 & 55.716246707523 & 90.5660981997201 & 99.7902966978924 \tabularnewline
27 & 73.1411724536216 & 46.3689569111740 & 55.6357616337525 & 90.6465832734907 & 99.9133879960692 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75948&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]73.1411724536216[/C][C]47.498040693459[/C][C]56.3740298367562[/C][C]89.908315070487[/C][C]98.7843042137841[/C][/ROW]
[ROW][C]19[/C][C]73.1411724536216[/C][C]47.3701439810567[/C][C]56.2904026715123[/C][C]89.9919422357308[/C][C]98.9122009261864[/C][/ROW]
[ROW][C]20[/C][C]73.1411724536216[/C][C]47.2428788689384[/C][C]56.2071884874962[/C][C]90.0751564197469[/C][C]99.0394660383047[/C][/ROW]
[ROW][C]21[/C][C]73.1411724536216[/C][C]47.1162360912953[/C][C]56.1243812261212[/C][C]90.1579636811219[/C][C]99.1661088159478[/C][/ROW]
[ROW][C]22[/C][C]73.1411724536216[/C][C]46.9902066066816[/C][C]56.0419749755036[/C][C]90.2403699317395[/C][C]99.2921383005615[/C][/ROW]
[ROW][C]23[/C][C]73.1411724536216[/C][C]46.8647815904815[/C][C]55.9599639655373[/C][C]90.3223809417058[/C][C]99.4175633167616[/C][/ROW]
[ROW][C]24[/C][C]73.1411724536216[/C][C]46.7399524276985[/C][C]55.8783425631789[/C][C]90.4040023440643[/C][C]99.5423924795446[/C][/ROW]
[ROW][C]25[/C][C]73.1411724536216[/C][C]46.6157107060498[/C][C]55.7971052679323[/C][C]90.4852396393109[/C][C]99.6666342011933[/C][/ROW]
[ROW][C]26[/C][C]73.1411724536216[/C][C]46.4920482093507[/C][C]55.716246707523[/C][C]90.5660981997201[/C][C]99.7902966978924[/C][/ROW]
[ROW][C]27[/C][C]73.1411724536216[/C][C]46.3689569111740[/C][C]55.6357616337525[/C][C]90.6465832734907[/C][C]99.9133879960692[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75948&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75948&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
1873.141172453621647.49804069345956.374029836756289.90831507048798.7843042137841
1973.141172453621647.370143981056756.290402671512389.991942235730898.9122009261864
2073.141172453621647.242878868938456.207188487496290.075156419746999.0394660383047
2173.141172453621647.116236091295356.124381226121290.157963681121999.1661088159478
2273.141172453621646.990206606681656.041974975503690.240369931739599.2921383005615
2373.141172453621646.864781590481555.959963965537390.322380941705899.4175633167616
2473.141172453621646.739952427698555.878342563178990.404002344064399.5423924795446
2573.141172453621646.615710706049855.797105267932390.485239639310999.6666342011933
2673.141172453621646.492048209350755.71624670752390.566098199720199.7902966978924
2773.141172453621646.368956911174055.635761633752590.646583273490799.9133879960692







Actuals and Interpolation
TimeActualForecast
166NA
258.6666666766
36665.266666667
451.3333333365.3400000003
573.1666666763.93933333327
665.8333333364.862066666943
765.1666666764.9591933332487
88064.9799406669238
98866.4819466002315
108668.6337519402083
1194.6743333370.3703767461875
1266.1666666772.8007724045687
1394.8333333372.1373618311119
1472.3333333374.4069589810007
1586.3333333374.1995964159006
1664.3333333375.4129701073106
1762.6666666774.3050064295795

\begin{tabular}{lllllllll}
\hline
Actuals and Interpolation \tabularnewline
Time & Actual & Forecast \tabularnewline
1 & 66 & NA \tabularnewline
2 & 58.66666667 & 66 \tabularnewline
3 & 66 & 65.266666667 \tabularnewline
4 & 51.33333333 & 65.3400000003 \tabularnewline
5 & 73.16666667 & 63.93933333327 \tabularnewline
6 & 65.83333333 & 64.862066666943 \tabularnewline
7 & 65.16666667 & 64.9591933332487 \tabularnewline
8 & 80 & 64.9799406669238 \tabularnewline
9 & 88 & 66.4819466002315 \tabularnewline
10 & 86 & 68.6337519402083 \tabularnewline
11 & 94.67433333 & 70.3703767461875 \tabularnewline
12 & 66.16666667 & 72.8007724045687 \tabularnewline
13 & 94.83333333 & 72.1373618311119 \tabularnewline
14 & 72.33333333 & 74.4069589810007 \tabularnewline
15 & 86.33333333 & 74.1995964159006 \tabularnewline
16 & 64.33333333 & 75.4129701073106 \tabularnewline
17 & 62.66666667 & 74.3050064295795 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=75948&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]66[/C][C]NA[/C][/ROW]
[ROW][C]2[/C][C]58.66666667[/C][C]66[/C][/ROW]
[ROW][C]3[/C][C]66[/C][C]65.266666667[/C][/ROW]
[ROW][C]4[/C][C]51.33333333[/C][C]65.3400000003[/C][/ROW]
[ROW][C]5[/C][C]73.16666667[/C][C]63.93933333327[/C][/ROW]
[ROW][C]6[/C][C]65.83333333[/C][C]64.862066666943[/C][/ROW]
[ROW][C]7[/C][C]65.16666667[/C][C]64.9591933332487[/C][/ROW]
[ROW][C]8[/C][C]80[/C][C]64.9799406669238[/C][/ROW]
[ROW][C]9[/C][C]88[/C][C]66.4819466002315[/C][/ROW]
[ROW][C]10[/C][C]86[/C][C]68.6337519402083[/C][/ROW]
[ROW][C]11[/C][C]94.67433333[/C][C]70.3703767461875[/C][/ROW]
[ROW][C]12[/C][C]66.16666667[/C][C]72.8007724045687[/C][/ROW]
[ROW][C]13[/C][C]94.83333333[/C][C]72.1373618311119[/C][/ROW]
[ROW][C]14[/C][C]72.33333333[/C][C]74.4069589810007[/C][/ROW]
[ROW][C]15[/C][C]86.33333333[/C][C]74.1995964159006[/C][/ROW]
[ROW][C]16[/C][C]64.33333333[/C][C]75.4129701073106[/C][/ROW]
[ROW][C]17[/C][C]62.66666667[/C][C]74.3050064295795[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=75948&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=75948&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
166NA
258.6666666766
36665.266666667
451.3333333365.3400000003
573.1666666763.93933333327
665.8333333364.862066666943
765.1666666764.9591933332487
88064.9799406669238
98866.4819466002315
108668.6337519402083
1194.6743333370.3703767461875
1266.1666666772.8007724045687
1394.8333333372.1373618311119
1472.3333333374.4069589810007
1586.3333333374.1995964159006
1664.3333333375.4129701073106
1762.6666666774.3050064295795







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

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