R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-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. > x <- c(8.9634 + ,8.9522 + ,8.8682 + ,8.7331 + ,8.3188 + ,8.3462 + ,8.3087 + ,8.3836 + ,8.8412 + ,9.5001 + ,10.1883 + ,10.2931 + ,10.1945 + ,10.3014 + ,10.0675 + ,9.6715 + ,9.5019 + ,9.4597 + ,9.4362 + ,9.5919 + ,10.0167 + ,10.322 + ,11.166 + ,11.5454 + ,11.3712 + ,11.0723 + ,10.813 + ,10.3016 + ,10.4227 + ,10.3162 + ,10.4519 + ,10.8567 + ,11.2716 + ,11.4341 + ,12.1273 + ,11.9814 + ,11.8352 + ,11.9847 + ,11.545 + ,11.5285 + ,11.5539 + ,11.622 + ,11.6578 + ,11.6767 + ,11.8752 + ,13.2643 + ,14.2297 + ,14.308 + ,13.7915 + ,13.7633 + ,13.9775 + ,13.6478 + ,13.2247 + ,13.0971 + ,13.1039 + ,13.206 + ,13.7901 + ,14.6457 + ,15.5764 + ,15.6102 + ,15.8855 + ,16.0137 + ,15.6186 + ,15.384 + ,15.2751 + ,15.0912 + ,14.9222 + ,15.6231 + ,16.6737 + ,17.6805 + ,19.1919 + ,19.1711 + ,18.5658 + ,18.1285 + ,16.791 + ,16.9468 + ,17.3164 + ,17.1816 + ,16.7627 + ,17.239 + ,17.8838 + ,18.9038 + ,20.0274 + ,20.0087 + ,19.6366 + ,19.8163 + ,18.8602 + ,17.9206 + ,17.6889 + ,17.84 + ,17.678 + ,17.7258 + ,18.5865 + ,19.9804 + ,21.1584 + ,21.2921 + ,20.9445 + ,20.5731 + ,19.3274 + ,17.7866 + ,17.7483 + ,17.5648 + ,17.4763 + ,17.7264 + ,18.5736 + ,19.9236 + ,21.3286 + ,20.7249 + ,20.3334 + ,19.7658 + ,18.7569 + ,17.6963 + ,17.7978 + ,18.1771 + ,18.3738 + ,18.1996 + ,18.8443 + ,20.1001 + ,21.2458 + ,20.8381 + ,20.1967 + ,19.8159 + ,18.5784 + ,19.21 + ,19.3419 + ,19.12 + ,19.1563 + ,18.9783 + ,20.2913 + ,22.5439 + ,23.2821 + ,22.6191 + ,22.1599 + ,21.2766 + ,19.0846 + ,18.9096 + ,18.8095 + ,20.1164 + ,20.7762 + ,20.9044 + ,22.0026 + ,23.6401 + ,25.04 + ,24.7185 + ,24.1752 + ,24.1382 + ,22.3949 + ,21.3743 + ,21.4911 + ,21.2187 + ,21.2137 + ,21.6735 + ,22.5096 + ,24.3097 + ,25.7989 + ,25.4376 + ,23.878 + ,23.6966 + ,23.3544 + ,21.1993 + ,22.0431 + ,22.0203 + ,21.886 + ,21.9771 + ,23.0759 + ,24.9859 + ,26.2614 + ,26.1127 + ,25.6296 + ,25.2926 + ,22.8146 + ,22.2974 + ,22.8868 + ,22.4612 + ,22.3165 + ,22.7319 + ,23.2692 + ,24.9432 + ,27.8272 + ,27.4059 + ,26.6232 + ,26.8779 + ,25.105 + ,23.601 + ,23.5374 + ,23.5248 + ,22.9465 + ,23.6633 + ,25.5932 + ,27.7683 + ,29.4691 + ,28.3472 + ,28.3879 + ,27.9696 + ,26.0075 + ,24.2533 + ,24.4999 + ,23.8988 + ,23.6683 + ,23.9427 + ,26.0155 + ,28.9529 + ,30.302 + ,29.874 + ,28.2257 + ,28.0811 + ,26.3398 + ,25.4847 + ,25.4823 + ,24.9697 + ,25.2282 + ,25.9257 + ,28.7818 + ,27.9552 + ,33.3475 + ,32.7834 + ,31.6586 + ,31.6613 + ,29.1839 + ,28.8825 + ,27.6334 + ,27.7511 + ,27.3792 + ,27.7748 + ,31.4329 + ,33.2735 + ,35.0962 + ,34.9537 + ,31.8307 + ,30.9984 + ,28.629 + ,26.4379 + ,25.4408 + ,24.6681 + ,24.0994 + ,24.6043 + ,27.2492 + ,29.5511 + ,29.8522 + ,31.6989 + ,29.6357 + ,30.5197 + ,32.7823 + ,24.9942 + ,23.5187 + ,24.0249 + ,24.5692 + ,24.402 + ,26.7089 + ,31.6874 + ,32.8801 + ,32.7906 + ,30.8785 + ,30.3024 + ,28.3679 + ,25.6578 + ,25.1598 + ,24.6143 + ,24.528 + ,25.2905 + ,30.0016 + ,34.2728 + ,34.4408 + ,34.1907 + ,33.6636 + ,33.9073 + ,30.2175 + ,28.5274 + ,25.9505 + ,26.2398 + ,26.2819 + ,26.7362 + ,28.8395 + ,31.0951 + ,33.7015 + ,33.8091 + ,32.1126 + ,32 + ,29.122 + ,26.8124 + ,25.4654 + ,23.8331 + ,24.714 + ,28.3288 + ,29.6391 + ,32.4542 + ,33.5657 + ,33.1856 + ,33.297 + ,33.51 + ,31.3789 + ,29.4555 + ,27.2699 + ,27.2586 + ,27.8591 + ,29.6362 + ,30.9587 + ,31.8633 + ,33.8188 + ,33.7531 + ,33.6103 + ,32.9052 + ,29.5005 + ,27.3634 + ,27.2298 + ,26.5211 + ,26.5228 + ,27.2991 + ,29.1726 + ,30.297 + ,32.5287 + ,32.487 + ,32.4197 + ,30.854 + ,28.6995 + ,27.7881 + ,26.5609 + ,25.9431 + ,25.5578 + ,27.1275 + ,30.2556 + ,34.0976 + ,34.5614 + ,34.2948 + ,33.3418 + ,31.8187 + ,29.0818 + ,27.3444 + ,26.6233 + ,26.1869 + ,26.2953 + ,28.7043 + ,32.0653 + ,34.5401 + ,34.6636 + ,34.2557 + ,32.0526 + ,30.6892 + ,28.012 + ,26.1528 + ,23.2276 + ,24.244 + ,24.8141 + ,27.8632 + ,29.6233 + ,32.4245 + ,33.3417 + ,33.0442 + ,32.0526 + ,30.2182 + ,28.9292 + ,26.8221 + ,26.1032 + ,25.9792 + ,27.1443 + ,29.4993 + ,31.656 + ,33.3665 + ,35.0521 + ,34.4076 + ,33.069 + ,31.5816 + ,30.0695 + ,29.0035 + ,28.6813 + ,28.359 + ,30.0447 + ,31.5073 + ,34.16 + ,35.57 + ,36.42 + ,35.12 + ,33.14 + ,30.29 + ,28.2 + ,26.5 + ,25.47 + ,24.96 + ,25.6 + ,27.76 + ,30.13 + ,32.35 + ,32.8 + ,32.54 + ,29.78 + ,28.79 + ,26.8 + ,25.41 + ,24.34 + ,24.39 + ,25 + ,26.27 + ,27.88 + ,29.35 + ,29.83 + ,29.46) > par20 = '' > par19 = '' > par18 = '' > par17 = '' > par16 = '' > par15 = '' > par14 = '' > par13 = '' > par12 = '' > par11 = '' > par10 = 'FALSE' > par9 = '1' > par8 = '0' > par7 = '1' > par6 = '1' > par5 = '12' > par4 = '1' > par3 = '1' > par2 = '-0.5' > par1 = '12' > 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: ar1 ma1 sma1 0.5627 -0.7496 -0.7573 s.e. 0.1133 0.0887 0.0414 sigma^2 estimated as 9.664e-06: log likelihood = 1610.38, aic = -3212.76 > (forecast <- predict(arima.out,par1)) $pred Time Series: Start = 385 End = 396 Frequency = 1 [1] 0.1786555 0.1831043 0.1893264 0.1951359 0.1990829 0.1999512 0.1974130 [8] 0.1906089 0.1832236 0.1772270 0.1746919 0.1758731 $se Time Series: Start = 385 End = 396 Frequency = 1 [1] 0.003108631 0.004006385 0.004570824 0.004995777 0.005349422 0.005661747 [7] 0.005947598 0.006214951 0.006468384 0.006710697 0.006943715 0.007168705 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 385 End = 396 Frequency = 1 [1] 0.1725626 0.1752518 0.1803676 0.1853441 0.1885980 0.1888542 0.1857557 [8] 0.1784276 0.1705456 0.1640741 0.1610822 0.1618224 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 385 End = 396 Frequency = 1 [1] 0.1847484 0.1909568 0.1982853 0.2049276 0.2095677 0.2110482 0.2090703 [8] 0.2027902 0.1959017 0.1903800 0.1883015 0.1899237 > 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] 8.96340 8.95220 8.86820 8.73310 8.31880 8.34620 8.30870 8.38360 [9] 8.84120 9.50010 10.18830 10.29310 10.19450 10.30140 10.06750 9.67150 [17] 9.50190 9.45970 9.43620 9.59190 10.01670 10.32200 11.16600 11.54540 [25] 11.37120 11.07230 10.81300 10.30160 10.42270 10.31620 10.45190 10.85670 [33] 11.27160 11.43410 12.12730 11.98140 11.83520 11.98470 11.54500 11.52850 [41] 11.55390 11.62200 11.65780 11.67670 11.87520 13.26430 14.22970 14.30800 [49] 13.79150 13.76330 13.97750 13.64780 13.22470 13.09710 13.10390 13.20600 [57] 13.79010 14.64570 15.57640 15.61020 15.88550 16.01370 15.61860 15.38400 [65] 15.27510 15.09120 14.92220 15.62310 16.67370 17.68050 19.19190 19.17110 [73] 18.56580 18.12850 16.79100 16.94680 17.31640 17.18160 16.76270 17.23900 [81] 17.88380 18.90380 20.02740 20.00870 19.63660 19.81630 18.86020 17.92060 [89] 17.68890 17.84000 17.67800 17.72580 18.58650 19.98040 21.15840 21.29210 [97] 20.94450 20.57310 19.32740 17.78660 17.74830 17.56480 17.47630 17.72640 [105] 18.57360 19.92360 21.32860 20.72490 20.33340 19.76580 18.75690 17.69630 [113] 17.79780 18.17710 18.37380 18.19960 18.84430 20.10010 21.24580 20.83810 [121] 20.19670 19.81590 18.57840 19.21000 19.34190 19.12000 19.15630 18.97830 [129] 20.29130 22.54390 23.28210 22.61910 22.15990 21.27660 19.08460 18.90960 [137] 18.80950 20.11640 20.77620 20.90440 22.00260 23.64010 25.04000 24.71850 [145] 24.17520 24.13820 22.39490 21.37430 21.49110 21.21870 21.21370 21.67350 [153] 22.50960 24.30970 25.79890 25.43760 23.87800 23.69660 23.35440 21.19930 [161] 22.04310 22.02030 21.88600 21.97710 23.07590 24.98590 26.26140 26.11270 [169] 25.62960 25.29260 22.81460 22.29740 22.88680 22.46120 22.31650 22.73190 [177] 23.26920 24.94320 27.82720 27.40590 26.62320 26.87790 25.10500 23.60100 [185] 23.53740 23.52480 22.94650 23.66330 25.59320 27.76830 29.46910 28.34720 [193] 28.38790 27.96960 26.00750 24.25330 24.49990 23.89880 23.66830 23.94270 [201] 26.01550 28.95290 30.30200 29.87400 28.22570 28.08110 26.33980 25.48470 [209] 25.48230 24.96970 25.22820 25.92570 28.78180 27.95520 33.34750 32.78340 [217] 31.65860 31.66130 29.18390 28.88250 27.63340 27.75110 27.37920 27.77480 [225] 31.43290 33.27350 35.09620 34.95370 31.83070 30.99840 28.62900 26.43790 [233] 25.44080 24.66810 24.09940 24.60430 27.24920 29.55110 29.85220 31.69890 [241] 29.63570 30.51970 32.78230 24.99420 23.51870 24.02490 24.56920 24.40200 [249] 26.70890 31.68740 32.88010 32.79060 30.87850 30.30240 28.36790 25.65780 [257] 25.15980 24.61430 24.52800 25.29050 30.00160 34.27280 34.44080 34.19070 [265] 33.66360 33.90730 30.21750 28.52740 25.95050 26.23980 26.28190 26.73620 [273] 28.83950 31.09510 33.70150 33.80910 32.11260 32.00000 29.12200 26.81240 [281] 25.46540 23.83310 24.71400 28.32880 29.63910 32.45420 33.56570 33.18560 [289] 33.29700 33.51000 31.37890 29.45550 27.26990 27.25860 27.85910 29.63620 [297] 30.95870 31.86330 33.81880 33.75310 33.61030 32.90520 29.50050 27.36340 [305] 27.22980 26.52110 26.52280 27.29910 29.17260 30.29700 32.52870 32.48700 [313] 32.41970 30.85400 28.69950 27.78810 26.56090 25.94310 25.55780 27.12750 [321] 30.25560 34.09760 34.56140 34.29480 33.34180 31.81870 29.08180 27.34440 [329] 26.62330 26.18690 26.29530 28.70430 32.06530 34.54010 34.66360 34.25570 [337] 32.05260 30.68920 28.01200 26.15280 23.22760 24.24400 24.81410 27.86320 [345] 29.62330 32.42450 33.34170 33.04420 32.05260 30.21820 28.92920 26.82210 [353] 26.10320 25.97920 27.14430 29.49930 31.65600 33.36650 35.05210 34.40760 [361] 33.06900 31.58160 30.06950 29.00350 28.68130 28.35900 30.04470 31.50730 [369] 34.16000 35.57000 36.42000 35.12000 33.14000 30.29000 28.20000 26.50000 [377] 25.47000 24.96000 25.60000 27.76000 30.13000 32.35000 32.80000 32.54000 [385] 31.33049 29.82655 27.89828 26.26188 25.23087 25.01221 25.65951 27.52414 [393] 29.78770 31.83758 32.76836 32.32968 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 385 End = 396 Frequency = 1 [1] 0.03666509 0.04674580 0.05194213 0.05533210 0.05830517 0.06172052 [7] 0.06604611 0.07204155 0.07867463 0.08507959 0.08985537 0.09244611 > postscript(file="/var/wessaorg/rcomp/tmp/1a0yo1386212461.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.mape <- array(0, dim=fx) > perf.mape1 <- 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) > 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.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.mse[1] = abs(perf.se[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.mse[i] = perf.mse[i-1] + perf.se[i] + perf.mse1[i] = perf.mse[i] / i + } > perf.rmse = sqrt(perf.mse1) > postscript(file="/var/wessaorg/rcomp/tmp/2sao71386212461.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] > lines(dum, lty=1) > lines(ub,lty=3) > lines(lb,lty=3) > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/3whl01386212461.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.mape1[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.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/4kl3q1386212461.tab") > > try(system("convert tmp/1a0yo1386212461.ps tmp/1a0yo1386212461.png",intern=TRUE)) character(0) > try(system("convert tmp/2sao71386212461.ps tmp/2sao71386212461.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.514 0.736 5.220