R version 2.8.0 (2008-10-20) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > x <- c(0.24,0.23,0.23,0.24,0.23,0.23,0.25,0.21,0.26,0.25,0.24,0.24,0.27,0.25,0.26,0.29,0.24,0.26,0.24,0.26,0.25,0.26,0.24,0.21,0.20,0.22,0.20,0.21,0.20,0.19,0.20,0.20,0.21,0.24,0.22,0.19,0.23,0.23,0.23,0.22,0.23,0.25,0.25,0.22,0.25,0.25,0.24,0.19,0.24,0.26,0.24,0.24,0.25,0.23,0.27,0.24,0.26,0.27,0.29,0.28,0.32,0.29,0.27,0.26,0.28,0.31,0.29,0.31,0.31,0.32,0.32,0.26,0.31,0.31,0.31,0.31,0.29,0.27,0.30,0.27,0.27,0.30,0.28,0.24,0.28,0.28,0.33,0.28,0.29,0.25,0.31,0.29,0.37,0.31,0.29,0.28,0.30,0.32,0.31,0.28,0.29,0.29,0.28,0.26,0.28,0.30,0.33,0.31,0.37,0.36,0.37,0.37,0.36,0.33,0.33,0.40,0.32,0.39,0.39,0.37,0.37,0.30,0.33,0.33,0.34,0.35,0.34,0.37,0.37,0.37,0.36,0.32,0.33,0.35,0.36,0.35,0.37,0.35,0.32,0.33,0.28,0.32,0.35,0.30,0.32,0.32,0.32,0.32,0.36,0.31,0.26,0.33,0.31,0.34,0.33,0.38,0.32,0.30,0.32,0.33,0.34,0.29,0.33,0.36,0.32,0.32,0.32,0.31,0.30,0.34,0.34,0.30,0.28,0.25,0.27,0.33,0.28,0.33,0.32,0.27,0.27,0.28,0.27,0.27,0.25,0.25,0.22,0.27) > par20 = '' > par19 = '' > par18 = '' > par17 = '' > par16 = '' > par15 = '' > par14 = '' > par13 = '' > par12 = '' > par11 = '' > par10 = 'FALSE' > par9 = '1' > par8 = '0' > par7 = '1' > par6 = '0' > par5 = '12' > par4 = '1' > par3 = '1' > par2 = '-0.2' > par1 = '12' > ylab = '' > xlab = '' > main = '' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > par1 <- as.numeric(par1) #cut off periods > par2 <- as.numeric(par2) #lambda > par3 <- as.numeric(par3) #degree of non-seasonal differencing > par4 <- as.numeric(par4) #degree of seasonal differencing > par5 <- as.numeric(par5) #seasonal period > par6 <- as.numeric(par6) #p > par7 <- as.numeric(par7) #q > par8 <- as.numeric(par8) #P > par9 <- as.numeric(par9) #Q > if (par10 == 'TRUE') par10 <- TRUE > if (par10 == 'FALSE') par10 <- FALSE > if (par2 == 0) x <- log(x) > if (par2 != 0) x <- x^par2 > lx <- length(x) > first <- lx - 2*par1 > nx <- lx - par1 > nx1 <- nx + 1 > fx <- lx - nx > if (fx < 1) { + fx <- par5 + nx1 <- lx + fx - 1 + first <- lx - 2*fx + } > first <- 1 > if (fx < 3) fx <- round(lx/10,0) > (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')) Call: arima(x = x[1:nx], order = c(par6, par3, par7), seasonal = list(order = c(par8, par4, par9), period = par5), include.mean = par10, method = "ML") Coefficients: ma1 sma1 -0.5665 -0.7842 s.e. 0.0723 0.0627 sigma^2 estimated as 0.0005037: log likelihood = 381.68, aic = -757.35 > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 177 End = 188 Frequency = 1 [1] 1.280240 1.266525 1.266293 1.279380 1.274791 1.273355 1.267358 1.276317 [9] 1.273187 1.295049 1.290771 1.266071 $se Time Series: Start = 177 End = 188 Frequency = 1 [1] 0.02244702 0.02446583 0.02633030 0.02807121 0.02970986 0.03126289 [7] 0.03274234 0.03415777 0.03551684 0.03682578 0.03808977 0.03931315 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 177 End = 188 Frequency = 1 [1] 1.236244 1.218572 1.214685 1.224360 1.216560 1.212080 1.203183 1.209368 [9] 1.203574 1.222871 1.216115 1.189017 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 177 End = 188 Frequency = 1 [1] 1.324236 1.314478 1.317900 1.334399 1.333022 1.334630 1.331533 1.343267 [9] 1.342800 1.367228 1.365427 1.343125 > if (par2 == 0) { + x <- exp(x) + forecast$pred <- exp(forecast$pred) + lb <- exp(lb) + ub <- exp(ub) + } > if (par2 != 0) { + x <- x^(1/par2) + forecast$pred <- forecast$pred^(1/par2) + lb <- lb^(1/par2) + ub <- ub^(1/par2) + } > if (par2 < 0) { + olb <- lb + lb <- ub + ub <- olb + } > (actandfor <- c(x[1:nx], forecast$pred)) [1] 0.2400000 0.2300000 0.2300000 0.2400000 0.2300000 0.2300000 0.2500000 [8] 0.2100000 0.2600000 0.2500000 0.2400000 0.2400000 0.2700000 0.2500000 [15] 0.2600000 0.2900000 0.2400000 0.2600000 0.2400000 0.2600000 0.2500000 [22] 0.2600000 0.2400000 0.2100000 0.2000000 0.2200000 0.2000000 0.2100000 [29] 0.2000000 0.1900000 0.2000000 0.2000000 0.2100000 0.2400000 0.2200000 [36] 0.1900000 0.2300000 0.2300000 0.2300000 0.2200000 0.2300000 0.2500000 [43] 0.2500000 0.2200000 0.2500000 0.2500000 0.2400000 0.1900000 0.2400000 [50] 0.2600000 0.2400000 0.2400000 0.2500000 0.2300000 0.2700000 0.2400000 [57] 0.2600000 0.2700000 0.2900000 0.2800000 0.3200000 0.2900000 0.2700000 [64] 0.2600000 0.2800000 0.3100000 0.2900000 0.3100000 0.3100000 0.3200000 [71] 0.3200000 0.2600000 0.3100000 0.3100000 0.3100000 0.3100000 0.2900000 [78] 0.2700000 0.3000000 0.2700000 0.2700000 0.3000000 0.2800000 0.2400000 [85] 0.2800000 0.2800000 0.3300000 0.2800000 0.2900000 0.2500000 0.3100000 [92] 0.2900000 0.3700000 0.3100000 0.2900000 0.2800000 0.3000000 0.3200000 [99] 0.3100000 0.2800000 0.2900000 0.2900000 0.2800000 0.2600000 0.2800000 [106] 0.3000000 0.3300000 0.3100000 0.3700000 0.3600000 0.3700000 0.3700000 [113] 0.3600000 0.3300000 0.3300000 0.4000000 0.3200000 0.3900000 0.3900000 [120] 0.3700000 0.3700000 0.3000000 0.3300000 0.3300000 0.3400000 0.3500000 [127] 0.3400000 0.3700000 0.3700000 0.3700000 0.3600000 0.3200000 0.3300000 [134] 0.3500000 0.3600000 0.3500000 0.3700000 0.3500000 0.3200000 0.3300000 [141] 0.2800000 0.3200000 0.3500000 0.3000000 0.3200000 0.3200000 0.3200000 [148] 0.3200000 0.3600000 0.3100000 0.2600000 0.3300000 0.3100000 0.3400000 [155] 0.3300000 0.3800000 0.3200000 0.3000000 0.3200000 0.3300000 0.3400000 [162] 0.2900000 0.3300000 0.3600000 0.3200000 0.3200000 0.3200000 0.3100000 [169] 0.3000000 0.3400000 0.3400000 0.3000000 0.2800000 0.2500000 0.2700000 [176] 0.3300000 0.2907656 0.3068532 0.3071349 0.2917447 0.2970331 0.2987121 [183] 0.3058466 0.2952612 0.2989094 0.2745163 0.2790959 0.3074043 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 177 End = 188 Frequency = 1 [1] 0.09748324 0.10860518 0.11799245 0.12541266 0.13436843 0.14267910 [7] 0.15137541 0.15774707 0.16563136 0.16942603 0.17704884 0.18817866 > postscript(file="/var/www/html/rcomp/tmp/1ydho1229425055.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > opar <- par(mar=c(4,4,2,2),las=1) > ylim <- c( min(x[first:nx],lb), max(x[first:nx],ub)) > plot(x,ylim=ylim,type='n',xlim=c(first,lx)) > usr <- par('usr') > rect(usr[1],usr[3],nx+1,usr[4],border=NA,col='lemonchiffon') > rect(nx1,usr[3],usr[2],usr[4],border=NA,col='lavender') > abline(h= (-3:3)*2 , col ='gray', lty =3) > polygon( c(nx1:lx,lx:nx1), c(lb,rev(ub)), col = 'orange', lty=2,border=NA) > lines(nx1:lx, lb , lty=2) > lines(nx1:lx, ub , lty=2) > lines(x, lwd=2) > lines(nx1:lx, forecast$pred , lwd=2 , col ='white') > box() > par(opar) > dev.off() null device 1 > prob.dec <- array(NA, dim=fx) > prob.sdec <- array(NA, dim=fx) > prob.ldec <- array(NA, dim=fx) > prob.pval <- array(NA, dim=fx) > perf.pe <- array(0, dim=fx) > perf.mape <- array(0, dim=fx) > perf.se <- array(0, dim=fx) > perf.mse <- array(0, dim=fx) > perf.rmse <- array(0, dim=fx) > for (i in 1:fx) { + locSD <- (ub[i] - forecast$pred[i]) / 1.96 + perf.pe[i] = (x[nx+i] - forecast$pred[i]) / forecast$pred[i] + perf.mape[i] = perf.mape[i] + abs(perf.pe[i]) + perf.se[i] = (x[nx+i] - forecast$pred[i])^2 + perf.mse[i] = perf.mse[i] + perf.se[i] + prob.dec[i] = pnorm((x[nx+i-1] - forecast$pred[i]) / locSD) + prob.sdec[i] = pnorm((x[nx+i-par5] - forecast$pred[i]) / locSD) + prob.ldec[i] = pnorm((x[nx] - forecast$pred[i]) / locSD) + prob.pval[i] = pnorm(abs(x[nx+i] - forecast$pred[i]) / locSD) + } > perf.mape = perf.mape / fx > perf.mse = perf.mse / fx > perf.rmse = sqrt(perf.mse) > postscript(file="/var/www/html/rcomp/tmp/2v95e1229425055.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(forecast$pred, pch=19, type='b',main='ARIMA Extrapolation Forecast', ylab='Forecast and 95% CI', xlab='time',ylim=c(min(lb),max(ub))) > dum <- forecast$pred > dum[1:12] <- x[(nx+1):lx] > lines(dum, lty=1) > lines(ub,lty=3) > lines(lb,lty=3) > dev.off() null device 1 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Univariate ARIMA Extrapolation Forecast',9,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'time',1,header=TRUE) > a<-table.element(a,'Y[t]',1,header=TRUE) > a<-table.element(a,'F[t]',1,header=TRUE) > a<-table.element(a,'95% LB',1,header=TRUE) > a<-table.element(a,'95% UB',1,header=TRUE) > a<-table.element(a,'p-value
(H0: Y[t] = F[t])',1,header=TRUE) > a<-table.element(a,'P(F[t]>Y[t-1])',1,header=TRUE) > a<-table.element(a,'P(F[t]>Y[t-s])',1,header=TRUE) > mylab <- paste('P(F[t]>Y[',nx,sep='') > mylab <- paste(mylab,'])',sep='') > a<-table.element(a,mylab,1,header=TRUE) > a<-table.row.end(a) > for (i in (nx-par5):nx) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,x[i]) + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.element(a,'-') + a<-table.row.end(a) + } > for (i in 1:fx) { + a<-table.row.start(a) + a<-table.element(a,nx+i,header=TRUE) + a<-table.element(a,round(x[nx+i],4)) + a<-table.element(a,round(forecast$pred[i],4)) + a<-table.element(a,round(lb[i],4)) + a<-table.element(a,round(ub[i],4)) + a<-table.element(a,round((1-prob.pval[i]),4)) + a<-table.element(a,round((1-prob.dec[i]),4)) + a<-table.element(a,round((1-prob.sdec[i]),4)) + a<-table.element(a,round((1-prob.ldec[i]),4)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/3ubu01229425055.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Univariate ARIMA Extrapolation Forecast Performance',7,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'time',1,header=TRUE) > a<-table.element(a,'% S.E.',1,header=TRUE) > a<-table.element(a,'PE',1,header=TRUE) > a<-table.element(a,'MAPE',1,header=TRUE) > a<-table.element(a,'Sq.E',1,header=TRUE) > a<-table.element(a,'MSE',1,header=TRUE) > a<-table.element(a,'RMSE',1,header=TRUE) > a<-table.row.end(a) > for (i in 1:fx) { + a<-table.row.start(a) + a<-table.element(a,nx+i,header=TRUE) + a<-table.element(a,round(perc.se[i],4)) + a<-table.element(a,round(perf.pe[i],4)) + a<-table.element(a,round(perf.mape[i],4)) + a<-table.element(a,round(perf.se[i],4)) + a<-table.element(a,round(perf.mse[i],4)) + a<-table.element(a,round(perf.rmse[i],4)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/48xqr1229425055.tab") > > system("convert tmp/1ydho1229425055.ps tmp/1ydho1229425055.png") > system("convert tmp/2v95e1229425055.ps tmp/2v95e1229425055.png") > > > proc.time() user system elapsed 0.823 0.318 0.934