 | :: ARIMA Forecasting - Free Statistics Software (Calculator) :: | |
|
All rights reserved. The non-commercial (academic) use of this software is free of charge. The only thing that is asked in return is to cite this software when results are used in publications.
This free online software (calculator) computes the extrapolation forecasts of a univariate ARIMA model for a time series Y[t] (for t = 1, 2, ..., T). The user may specify a cut-off period K which implies that the ARIMA model is estimated based on Y[t] for t = 1, 2, ..., T-K and such that the extrapolation forecast F[t] for t = T-K+1, ..., T is computed and compared with the actual values that were dropped: various extrapolation forecast statistics are computed (MPE, RMSE, MAPE, ...). In addition, the following probabilities are computed: P(F[t]>Y[t-1]), P(F[t]>Y[t-s]), and P(F[t]>Y[T-K]).
Click here to edit the underlying code of this R Module.Enter (or paste) your data delimited by hard returns. Click here to edit the underlying code of this R Module.
| Cite this software as: | | Wessa P., (2008), ARIMA Forecasting (v1.0.4) in Free Statistics Software (v1.1.22-r6), Office for Research Development and Education, URL http://www.wessa.net/rwasp_arimaforecasting.wasp/ | | | The R code is based on : | | | Borghers, E, and P. Wessa, Statistics - Econometrics - Forecasting, Office for Research Development and Education, http://www.xycoon.com/ | | | | | | | | | | | | | |
|
| Source code of R module | | 1 | par1 <- as.numeric(par1) #cut off periods | | 2 | par2 <- as.numeric(par2) #lambda | | 3 | par3 <- as.numeric(par3) #degree of non-seasonal differencing | | 4 | par4 <- as.numeric(par4) #degree of seasonal differencing | | 5 | par5 <- as.numeric(par5) #seasonal period | | 6 | par6 <- as.numeric(par6) #p | | 7 | par7 <- as.numeric(par7) #q | | 8 | par8 <- as.numeric(par8) #P | | 9 | par9 <- as.numeric(par9) #Q | | 10 | if (par10 == "TRUE") par10 <- TRUE | | 11 | if (par10 == "FALSE") par10 <- FALSE | | 12 | if (par2 == 0) x <- log(x) | | 13 | if (par2 != 0) x <- x^par2 | | 14 | lx <- length(x) | | 15 | first <- lx - 2*par1 | | 16 | nx <- lx - par1 | | 17 | nx1 <- nx + 1 | | 18 | fx <- lx - nx | | 19 | if (fx < 1) { | | 20 | fx <- par5 | | 21 | nx1 <- lx + fx - 1 | | 22 | first <- lx - 2*fx | | 23 | } | | 24 | first <- 1 | | 25 | if (fx < 3) fx <- round(lx/10,0) | | 26 | (arima.out <- arima(x[1:nx], order=c(par6,par3,par7), seasonal=list(order=c(par8,par4,par9), period=par5), include.mean=par10, method="ML")) | | 27 | (forecast <- predict(arima.out,fx)) | | 28 | (lb <- forecast$pred - 1.96 * forecast$se) | | 29 | (ub <- forecast$pred + 1.96 * forecast$se) | | 30 | if (par2 == 0) { | | 31 | x <- exp(x) | | 32 | forecast$pred <- exp(forecast$pred) | | 33 | lb <- exp(lb) | | 34 | ub <- exp(ub) | | 35 | } | | 36 | if (par2 != 0) { | | 37 | x <- x^(1/par2) | | 38 | forecast$pred <- forecast$pred^(1/par2) | | 39 | lb <- lb^(1/par2) | | 40 | ub <- ub^(1/par2) | | 41 | } | | 42 | if (par2 < 0) { | | 43 | olb <- lb | | 44 | lb <- ub | | 45 | ub <- olb | | 46 | } | | 47 | (actandfor <- c(x[1:nx], forecast$pred)) | | 48 | (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) | | 49 | bitmap(file="test1.png") | | 50 | opar <- par(mar=c(4,4,2,2),las=1) | | 51 | ylim <- c( min(x[first:nx],lb), max(x[first:nx],ub)) | | 52 | plot(x,ylim=ylim,type="n",xlim=c(first,lx)) | | 53 | usr <- par("usr") | | 54 | rect(usr[1],usr[3],nx+1,usr[4],border=NA,col="lemonchiffon") | | 55 | rect(nx1,usr[3],usr[2],usr[4],border=NA,col="lavender") | | 56 | abline(h= (-3:3)*2 , col ="gray", lty =3) | | 57 | polygon( c(nx1:lx,lx:nx1), c(lb,rev(ub)), col = "orange", lty=2,border=NA) | | 58 | lines(nx1:lx, lb , lty=2) | | 59 | lines(nx1:lx, ub , lty=2) | | 60 | lines(x, lwd=2) | | 61 | lines(nx1:lx, forecast$pred , lwd=2 , col ="white") | | 62 | box() | | 63 | par(opar) | | 64 | dev.off() | | 65 | prob.dec <- array(NA, dim=fx) | | 66 | prob.sdec <- array(NA, dim=fx) | | 67 | prob.ldec <- array(NA, dim=fx) | | 68 | prob.pval <- array(NA, dim=fx) | | 69 | perf.pe <- array(0, dim=fx) | | 70 | perf.mape <- array(0, dim=fx) | | 71 | perf.se <- array(0, dim=fx) | | 72 | perf.mse <- array(0, dim=fx) | | 73 | perf.rmse <- array(0, dim=fx) | | 74 | for (i in 1:fx) { | | 75 | locSD <- (ub[i] - forecast$pred[i]) / 1.96 | | 76 | perf.pe[i] = (x[nx+i] - forecast$pred[i]) / forecast$pred[i] | | 77 | perf.mape[i] = perf.mape[i] + abs(perf.pe[i]) | | 78 | perf.se[i] = (x[nx+i] - forecast$pred[i])^2 | | 79 | perf.mse[i] = perf.mse[i] + perf.se[i] | | 80 | prob.dec[i] = pnorm((x[nx+i-1] - forecast$pred[i]) / locSD) | | 81 | prob.sdec[i] = pnorm((x[nx+i-par5] - forecast$pred[i]) / locSD) | | 82 | prob.ldec[i] = pnorm((x[nx] - forecast$pred[i]) / locSD) | | 83 | prob.pval[i] = pnorm(abs(x[nx+i] - forecast$pred[i]) / locSD) | | 84 | } | | 85 | perf.mape = perf.mape / fx | | 86 | perf.mse = perf.mse / fx | | 87 | perf.rmse = sqrt(perf.mse) | | 88 | bitmap(file="test2.png") | | 89 | plot(forecast$pred, pch=19, type="b",main="ARIMA Extrapolation Forecast", ylab="Forecast and 95% CI", xlab="time",ylim=c(min(lb),max(ub))) | | 90 | dum <- forecast$pred | | 91 | dum[1:12] <- x[(nx+1):lx] | | 92 | lines(dum, lty=1) | | 93 | lines(ub,lty=3) | | 94 | lines(lb,lty=3) | | 95 | dev.off() | | 96 | load(file="createtable") | | 97 | a<-table.start() | | 98 | a<-table.row.start(a) | | 99 | a<-table.element(a,"Univariate ARIMA Extrapolation Forecast",9,TRUE) | | 100 | a<-table.row.end(a) | | 101 | a<-table.row.start(a) | | 102 | a<-table.element(a,"time",1,header=TRUE) | | 103 | a<-table.element(a,"Y[t]",1,header=TRUE) | | 104 | a<-table.element(a,"F[t]",1,header=TRUE) | | 105 | a<-table.element(a,"95% LB",1,header=TRUE) | | 106 | a<-table.element(a,"95% UB",1,header=TRUE) | | 107 | a<-table.element(a,"p-value (H0: Y[t] = F[t])",1,header=TRUE) | | 108 | a<-table.element(a,"P(F[t]>Y[t-1])",1,header=TRUE) | | 109 | a<-table.element(a,"P(F[t]>Y[t-s])",1,header=TRUE) | | 110 | mylab <- paste("P(F[t]>Y[",nx,sep="") | | 111 | mylab <- paste(mylab,"])",sep="") | | 112 | a<-table.element(a,mylab,1,header=TRUE) | | 113 | a<-table.row.end(a) | | 114 | for (i in (nx-par5):nx) { | | 115 | a<-table.row.start(a) | | 116 | a<-table.element(a,i,header=TRUE) | | 117 | a<-table.element(a,x[i]) | | 118 | a<-table.element(a,"-") | | 119 | a<-table.element(a,"-") | | 120 | a<-table.element(a,"-") | | 121 | a<-table.element(a,"-") | | 122 | a<-table.element(a,"-") | | 123 | a<-table.element(a,"-") | | 124 | a<-table.element(a,"-") | | 125 | a<-table.row.end(a) | | 126 | } | | 127 | for (i in 1:fx) { | | 128 | a<-table.row.start(a) | | 129 | a<-table.element(a,nx+i,header=TRUE) | | 130 | a<-table.element(a,round(x[nx+i],4)) | | 131 | a<-table.element(a,round(forecast$pred[i],4)) | | 132 | a<-table.element(a,round(lb[i],4)) | | 133 | a<-table.element(a,round(ub[i],4)) | | 134 | a<-table.element(a,round((1-prob.pval[i]),4)) | | 135 | a<-table.element(a,round((1-prob.dec[i]),4)) | | 136 | a<-table.element(a,round((1-prob.sdec[i]),4)) | | 137 | a<-table.element(a,round((1-prob.ldec[i]),4)) | | 138 | a<-table.row.end(a) | | 139 | } | | 140 | a<-table.end(a) | | 141 | table.save(a,file="mytable.tab") | | 142 | a<-table.start() | | 143 | a<-table.row.start(a) | | 144 | a<-table.element(a,"Univariate ARIMA Extrapolation Forecast Performance",7,TRUE) | | 145 | a<-table.row.end(a) | | 146 | a<-table.row.start(a) | | 147 | a<-table.element(a,"time",1,header=TRUE) | | 148 | a<-table.element(a,"% S.E.",1,header=TRUE) | | 149 | a<-table.element(a,"PE",1,header=TRUE) | | 150 | a<-table.element(a,"MAPE",1,header=TRUE) | | 151 | a<-table.element(a,"Sq.E",1,header=TRUE) | | 152 | a<-table.element(a,"MSE",1,header=TRUE) | | 153 | a<-table.element(a,"RMSE",1,header=TRUE) | | 154 | a<-table.row.end(a) | | 155 | for (i in 1:fx) { | | 156 | a<-table.row.start(a) | | 157 | a<-table.element(a,nx+i,header=TRUE) | | 158 | a<-table.element(a,round(perc.se[i],4)) | | 159 | a<-table.element(a,round(perf.pe[i],4)) | | 160 | a<-table.element(a,round(perf.mape[i],4)) | | 161 | a<-table.element(a,round(perf.se[i],4)) | | 162 | a<-table.element(a,round(perf.mse[i],4)) | | 163 | a<-table.element(a,round(perf.rmse[i],4)) | | 164 | a<-table.row.end(a) | | 165 | } | | 166 | a<-table.end(a) | | 167 | table.save(a,file="mytable1.tab") |
|
To cite Wessa.net in publications use: Wessa, P. (2008), Free Statistics Software, Office for Research Development and Education, version 1.1.22-r6, URL http://www.wessa.net/
© Resa
R&D, and the 'Office for Research, Development, and Education' - All rights reserved. Academic license for non-commercial use only. This website is an intellectual
and physical property of Resa R&D. This includes: html content,
graphical illustrations (gif files), computer software, online or electronic
documentation, associated media, and printed materials. The free use of the scientific content, services, and applications in this website is
granted for non commercial use only. In any case,
the source (url) should always be clearly displayed. Under no circumstances are
you allowed to reproduce, copy or redistribute the design, layout, or any
content of this website (for commercial use) including any materials contained
herein without the express written permission of Resa R&D or the Office for Research, Development, and Education.
Information provided
on this web site is provided "AS IS" without warranty of any kind, either
express or implied, including, without limitation, warranties of
merchantability, fitness for a particular purpose, and noninfringement. We use reasonable efforts to include accurate and timely information
and periodically update the information, and software without notice. However, Resa
R&D makes no warranties or representations
as to the accuracy or completeness of such information (or software), and it assumes no
liability or responsibility for errors or omissions in the content of this web
site, or any software bugs in online applications. Your use of this web site is AT YOUR OWN RISK. Under no circumstances and
under no legal theory shall Resa R&D be liable to you or any other
person for any direct, indirect, special, incidental, exemplary, or
consequential damages arising from your access to, or use of, this web site.
Software Version : 1.1.22-r6 Algorithms & Software : Prof. dr. P. Wessa Facilities : Resa R&D - Office for Research, Development, and Education Server : www.wessa.net
Comments, Feedback & Errors | Privacy Policy | Statistics Resources | Wessa.net Home
|
|
|