R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree" Copyright (C) 2017 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) 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. > source('/home/pw/wessanet/cretab') > > > > myrfcuid = 'r0386985' > > x <- c(62.4,67.4,76.1,67.4,74.5,72.6,60.5,66.1,76.5,76.8,77,71,74.8,73.7,80.5,71.8,76.9,79.9,65.9,69.5,75.1,79.6,75.2,68,72.8,71.5,78.5,76.8,75.3,76.7,69.7,67.8,77.5,82.5,75.3,70.9,76,73.7,79.7,77.8,73.3,78.3,71.9,67,82,83.7,74.8,80,74.3,76.8,89,81.9,76.8,88.9,75.8,75.5,89.1,88,85.9,89.3,82.9,81.2,90.5,86.4,81.8,91.3,73.4,76.6,91,87,89.7,90.7,86.5,86.6,98.8,84.4,91.4,95.7,78.5,81.7,94.3,98.5,95.4,91.7,92.8,90.5,102.2,91.8,95,102,88.9,89.6,97.9,108.6,100.8,95.1,101,100.9,102.5,105.4,98.4,105.3,96.5,88.1,107.9,107,92.5,95.7,85.2,85.5,94.7,86.2,88.8,93.4,83.4,82.9,96.7,96.2,92.8,92.8,90,95.4,108.3,96.3,95,109,92,92.3,107,105.5,105.4,103.9,99.2,102.2,121.5,102.3,110,105.9,91.9,100,111.7,104.9,103.3,101.8,100.8,104.2,116.5,97.9,100.7,107,96.3,96,104.5,107.4,102.4,94.9,98.8,96.8,108.2,103.8,102.3,107.2,102,92.6,105.2,113,105.6,101.6,101.7,102.7,109,105.5,103.3,108.6,98.2,90,112.4,111.9,102.1,102.4,101.7,98.7,114,105.1,98.3,110,96.5,92.2,112,111.4,107.5,103.4,103.5,107.4,117.6,110.2,104.3,115.9,98.9,101.9,113.5,109.5,110,114.2,106.9,109.2,124.2,104.7,111.9,119,102.9,106.3) > par10 = 'FALSE' > par9 = '1' > par8 = '2' > par7 = '1' > par6 = '0' > par5 = '12' > par4 = '1' > par3 = '0' > par2 = '1' > par1 = '0' > par10 <- 'FALSE' > par9 <- '1' > par8 <- '2' > par7 <- '1' > par6 <- '0' > par5 <- '12' > par4 <- '1' > par3 <- '0' > par2 <- '1' > par1 <- '0' > #'GNU S' R Code compiled by R2WASP v. 1.2.327 (Wed, 16 Nov 2016 12:47:20 +0100) > #Author: root > #To cite this work: Wessa P., (2016), ARIMA Forecasting (v1.0.10) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_arimaforecasting.wasp/ > #Source of accompanying publication: > # > 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*2 + 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 sar1 sar2 sma1 0.5029 -0.1031 -0.1359 -0.0693 s.e. 0.0702 0.5915 0.1142 0.6073 sigma^2 estimated as 29.03: log likelihood = -621.16, aic = 1252.31 > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 213 End = 236 Frequency = 1 [1] 115.1796 109.9088 108.8041 112.1768 106.0455 107.6404 122.4780 104.8972 [9] 109.7526 117.5776 101.8751 104.0864 114.6671 110.1248 108.5877 110.9178 [17] 105.6716 107.5566 121.7587 105.6242 108.9413 117.3031 101.4372 103.7168 $se Time Series: Start = 213 End = 236 Frequency = 1 [1] 5.387782 6.030759 6.030759 6.030759 6.030759 6.030759 6.030759 6.030759 [9] 6.030759 6.030759 6.030759 6.030759 7.499908 7.827921 7.827921 7.827921 [17] 7.827921 7.827921 7.827921 7.827921 7.827921 7.827921 7.827921 7.827921 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 213 End = 236 Frequency = 1 [1] 104.61960 98.08851 96.98378 100.35654 94.22520 95.82011 110.65772 [8] 93.07688 97.93230 105.75736 90.05481 92.26614 99.96733 94.78211 [15] 93.24496 95.57511 90.32886 92.21392 106.41599 90.28152 93.59855 [22] 101.96035 86.09450 88.37407 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 213 End = 236 Frequency = 1 [1] 125.7397 121.7291 120.6244 123.9971 117.8658 119.4607 134.2983 116.7175 [9] 121.5729 129.3979 113.6954 115.9067 129.3670 125.4676 123.9304 126.2606 [17] 121.0143 122.8994 137.1014 120.9670 124.2840 132.6458 116.7800 119.0595 > 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] 62.4000 67.4000 76.1000 67.4000 74.5000 72.6000 60.5000 66.1000 [9] 76.5000 76.8000 77.0000 71.0000 74.8000 73.7000 80.5000 71.8000 [17] 76.9000 79.9000 65.9000 69.5000 75.1000 79.6000 75.2000 68.0000 [25] 72.8000 71.5000 78.5000 76.8000 75.3000 76.7000 69.7000 67.8000 [33] 77.5000 82.5000 75.3000 70.9000 76.0000 73.7000 79.7000 77.8000 [41] 73.3000 78.3000 71.9000 67.0000 82.0000 83.7000 74.8000 80.0000 [49] 74.3000 76.8000 89.0000 81.9000 76.8000 88.9000 75.8000 75.5000 [57] 89.1000 88.0000 85.9000 89.3000 82.9000 81.2000 90.5000 86.4000 [65] 81.8000 91.3000 73.4000 76.6000 91.0000 87.0000 89.7000 90.7000 [73] 86.5000 86.6000 98.8000 84.4000 91.4000 95.7000 78.5000 81.7000 [81] 94.3000 98.5000 95.4000 91.7000 92.8000 90.5000 102.2000 91.8000 [89] 95.0000 102.0000 88.9000 89.6000 97.9000 108.6000 100.8000 95.1000 [97] 101.0000 100.9000 102.5000 105.4000 98.4000 105.3000 96.5000 88.1000 [105] 107.9000 107.0000 92.5000 95.7000 85.2000 85.5000 94.7000 86.2000 [113] 88.8000 93.4000 83.4000 82.9000 96.7000 96.2000 92.8000 92.8000 [121] 90.0000 95.4000 108.3000 96.3000 95.0000 109.0000 92.0000 92.3000 [129] 107.0000 105.5000 105.4000 103.9000 99.2000 102.2000 121.5000 102.3000 [137] 110.0000 105.9000 91.9000 100.0000 111.7000 104.9000 103.3000 101.8000 [145] 100.8000 104.2000 116.5000 97.9000 100.7000 107.0000 96.3000 96.0000 [153] 104.5000 107.4000 102.4000 94.9000 98.8000 96.8000 108.2000 103.8000 [161] 102.3000 107.2000 102.0000 92.6000 105.2000 113.0000 105.6000 101.6000 [169] 101.7000 102.7000 109.0000 105.5000 103.3000 108.6000 98.2000 90.0000 [177] 112.4000 111.9000 102.1000 102.4000 101.7000 98.7000 114.0000 105.1000 [185] 98.3000 110.0000 96.5000 92.2000 112.0000 111.4000 107.5000 103.4000 [193] 103.5000 107.4000 117.6000 110.2000 104.3000 115.9000 98.9000 101.9000 [201] 113.5000 109.5000 110.0000 114.2000 106.9000 109.2000 124.2000 104.7000 [209] 111.9000 119.0000 102.9000 106.3000 115.1796 109.9088 108.8041 112.1768 [217] 106.0455 107.6404 122.4780 104.8972 109.7526 117.5776 101.8751 104.0864 [225] 114.6671 110.1248 108.5877 110.9178 105.6716 107.5566 121.7587 105.6242 [233] 108.9413 117.3031 101.4372 103.7168 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 213 End = 236 Frequency = 1 [1] 0.04677720 0.05487058 0.05542770 0.05376118 0.05686955 0.05602691 [7] 0.04923952 0.05749211 0.05494867 0.05129172 0.05919758 0.05793992 [13] 0.06540590 0.07108225 0.07208848 0.07057405 0.07407783 0.07277952 [19] 0.06429044 0.07411102 0.07185450 0.06673245 0.07717010 0.07547399 > postscript(file="/home/pw/wessanet/rcomp/tmp/1rg6v1517477546.ps",horizontal=F,onefile=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.spe <- array(0, dim=fx) > perf.scalederr <- array(0, dim=fx) > perf.mase <- array(0, dim=fx) > perf.mase1 <- array(0, dim=fx) > perf.mape <- array(0, dim=fx) > perf.smape <- array(0, dim=fx) > perf.mape1 <- array(0, dim=fx) > perf.smape1 <- array(0,dim=fx) > perf.se <- array(0, dim=fx) > perf.mse <- array(0, dim=fx) > perf.mse1 <- array(0, dim=fx) > perf.rmse <- array(0, dim=fx) > perf.scaleddenom <- 0 > for (i in 2:fx) { + perf.scaleddenom = perf.scaleddenom + abs(x[nx+i] - x[nx+i-1]) + } > perf.scaleddenom = perf.scaleddenom / (fx-1) > for (i in 1:fx) { + locSD <- (ub[i] - forecast$pred[i]) / 1.96 + perf.scalederr[i] = (x[nx+i] - forecast$pred[i]) / perf.scaleddenom + perf.pe[i] = (x[nx+i] - forecast$pred[i]) / x[nx+i] + perf.spe[i] = 2*(x[nx+i] - forecast$pred[i]) / (x[nx+i] + forecast$pred[i]) + perf.se[i] = (x[nx+i] - forecast$pred[i])^2 + 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[1] = abs(perf.pe[1]) > perf.smape[1] = abs(perf.spe[1]) > perf.mape1[1] = perf.mape[1] > perf.smape1[1] = perf.smape[1] > perf.mse[1] = perf.se[1] > perf.mase[1] = abs(perf.scalederr[1]) > perf.mase1[1] = perf.mase[1] > for (i in 2:fx) { + perf.mape[i] = perf.mape[i-1] + abs(perf.pe[i]) + perf.mape1[i] = perf.mape[i] / i + perf.smape[i] = perf.smape[i-1] + abs(perf.spe[i]) + perf.smape1[i] = perf.smape[i] / i + perf.mse[i] = perf.mse[i-1] + perf.se[i] + perf.mse1[i] = perf.mse[i] / i + perf.mase[i] = perf.mase[i-1] + abs(perf.scalederr[i]) + perf.mase1[i] = perf.mase[i] / i + } > perf.rmse = sqrt(perf.mse1) > postscript(file="/home/pw/wessanet/rcomp/tmp/22qph1517477546.ps",horizontal=F,onefile=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:par1] <- x[(nx+1):lx] Warning message: In NextMethod("[<-") : number of items to replace is not a multiple of replacement length > lines(dum, lty=1) > lines(ub,lty=3) > lines(lb,lty=3) > dev.off() null device 1 > > 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="/home/pw/wessanet/rcomp/tmp/3ssi41517477546.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Univariate ARIMA Extrapolation Forecast Performance',10,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,'sMAPE',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.element(a,'ScaledE',1,header=TRUE) > a<-table.element(a,'MASE',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.mape1[i],4)) + a<-table.element(a,round(perf.smape1[i],4)) + a<-table.element(a,round(perf.se[i],4)) + a<-table.element(a,round(perf.mse1[i],4)) + a<-table.element(a,round(perf.rmse[i],4)) + a<-table.element(a,round(perf.scalederr[i],4)) + a<-table.element(a,round(perf.mase1[i],4)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/home/pw/wessanet/rcomp/tmp/4cmye1517477546.tab") > > try(system("convert /home/pw/wessanet/rcomp/tmp/1rg6v1517477546.ps /home/pw/wessanet/rcomp/tmp/1rg6v1517477546.png",intern=TRUE)) character(0) > try(system("convert /home/pw/wessanet/rcomp/tmp/22qph1517477546.ps /home/pw/wessanet/rcomp/tmp/22qph1517477546.png",intern=TRUE)) character(0) > > proc.time() user system elapsed 3.344 0.328 3.761