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(46402 + ,45329 + ,42185 + ,49341 + ,50472 + ,33020 + ,29567 + ,22870 + ,25730 + ,32609 + ,23536 + ,15135 + ,36776 + ,29982 + ,38062 + ,34226 + ,24906 + ,30233 + ,27405 + ,20784 + ,22886 + ,25425 + ,20838 + ,15655 + ,37158 + ,36364 + ,43213 + ,31635 + ,30113 + ,29985 + ,20919 + ,19429 + ,21427 + ,26064 + ,20109 + ,15369 + ,35466 + ,25954 + ,33504 + ,28115 + ,28501 + ,28618 + ,21434 + ,20177 + ,21484 + ,25642 + ,23515 + ,12941 + ,36190 + ,37785 + ,38407 + ,33326 + ,30304 + ,27576 + ,27048 + ,17291 + ,21018 + ,26792 + ,19426 + ,13927 + ,35647 + ,31746 + ,31277 + ,31583 + ,25607 + ,28151 + ,24947 + ,18077 + ,23429 + ,26313 + ,18862 + ,14753 + ,36409 + ,33163 + ,34122 + ,35225 + ,28249 + ,30374 + ,26311 + ,22069 + ,23651 + ,28628 + ,23187 + ,14727 + ,43080 + ,32519 + ,39657 + ,33614 + ,28671 + ,34243 + ,27336 + ,22916 + ,24537 + ,26128 + ,22602 + ,15744 + ,41086 + ,39690 + ,43129 + ,37863 + ,35953 + ,29133 + ,24693 + ,22205 + ,21725 + ,27192 + ,21790 + ,13253 + ,37702 + ,30364 + ,32609 + ,30212 + ,29965 + ,28352 + ,25814 + ,22414 + ,20506 + ,28806 + ,22228 + ,13971 + ,36845 + ,35338 + ,35022 + ,34777 + ,26887 + ,23970 + ,22780 + ,17351 + ,21382 + ,24561 + ,17409 + ,11514 + ,31514 + ,27071 + ,29462 + ,26105 + ,22397 + ,23843 + ,21705 + ,18089 + ,20764 + ,25316 + ,17704 + ,15548 + ,28029 + ,29383 + ,36438 + ,32034 + ,22679 + ,24319 + ,18004 + ,17537 + ,20366 + ,22782 + ,19169 + ,13807 + ,29743 + ,25591 + ,29096 + ,26482 + ,22405 + ,27044 + ,17970 + ,18730 + ,19684 + ,19785 + ,18479 + ,10698 + ,31956 + ,29506 + ,34506 + ,27165 + ,26736 + ,23691 + ,18157 + ,17328 + ,18205 + ,20995 + ,17382 + ,9367 + ,31124 + ,26551 + ,30651 + ,25859 + ,25100 + ,25778 + ,20418 + ,18688 + ,20424 + ,24776 + ,19814 + ,12738) > par10 = 'FALSE' > par9 = '1' > par8 = '0' > par7 = '1' > par6 = '3' > par5 = '12' > par4 = '1' > par3 = '1' > par2 = '-0.6' > par1 = '12' > #'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: ar1 ar2 ar3 ma1 sma1 0.0568 0.1684 0.2633 -0.8929 -0.8995 s.e. 0.1161 0.1083 0.0973 0.0821 0.1018 sigma^2 estimated as 1.900e-08: log likelihood = 1237.16, aic = -2462.31 > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 181 End = 192 Frequency = 1 [1] 0.002240001 0.002429107 0.002378425 0.002390483 0.002592948 0.002593225 [7] 0.002845522 0.003068878 0.002919013 0.002687525 0.003020015 0.003768099 $se Time Series: Start = 181 End = 192 Frequency = 1 [1] 0.0001385106 0.0001403572 0.0001457963 0.0001566691 0.0001596518 [6] 0.0001637992 0.0001679704 0.0001708461 0.0001739123 0.0001767914 [11] 0.0001793784 0.0001819431 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 181 End = 192 Frequency = 1 [1] 0.001968520 0.002154007 0.002092665 0.002083412 0.002280030 0.002272178 [7] 0.002516300 0.002734020 0.002578145 0.002341014 0.002668433 0.003411490 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 181 End = 192 Frequency = 1 [1] 0.002511481 0.002704207 0.002664186 0.002697555 0.002905865 0.002914271 [7] 0.003174744 0.003403737 0.003259881 0.003034036 0.003371596 0.004124707 > 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] 46402.00 45329.00 42185.00 49341.00 50472.00 33020.00 29567.00 22870.00 [9] 25730.00 32609.00 23536.00 15135.00 36776.00 29982.00 38062.00 34226.00 [17] 24906.00 30233.00 27405.00 20784.00 22886.00 25425.00 20838.00 15655.00 [25] 37158.00 36364.00 43213.00 31635.00 30113.00 29985.00 20919.00 19429.00 [33] 21427.00 26064.00 20109.00 15369.00 35466.00 25954.00 33504.00 28115.00 [41] 28501.00 28618.00 21434.00 20177.00 21484.00 25642.00 23515.00 12941.00 [49] 36190.00 37785.00 38407.00 33326.00 30304.00 27576.00 27048.00 17291.00 [57] 21018.00 26792.00 19426.00 13927.00 35647.00 31746.00 31277.00 31583.00 [65] 25607.00 28151.00 24947.00 18077.00 23429.00 26313.00 18862.00 14753.00 [73] 36409.00 33163.00 34122.00 35225.00 28249.00 30374.00 26311.00 22069.00 [81] 23651.00 28628.00 23187.00 14727.00 43080.00 32519.00 39657.00 33614.00 [89] 28671.00 34243.00 27336.00 22916.00 24537.00 26128.00 22602.00 15744.00 [97] 41086.00 39690.00 43129.00 37863.00 35953.00 29133.00 24693.00 22205.00 [105] 21725.00 27192.00 21790.00 13253.00 37702.00 30364.00 32609.00 30212.00 [113] 29965.00 28352.00 25814.00 22414.00 20506.00 28806.00 22228.00 13971.00 [121] 36845.00 35338.00 35022.00 34777.00 26887.00 23970.00 22780.00 17351.00 [129] 21382.00 24561.00 17409.00 11514.00 31514.00 27071.00 29462.00 26105.00 [137] 22397.00 23843.00 21705.00 18089.00 20764.00 25316.00 17704.00 15548.00 [145] 28029.00 29383.00 36438.00 32034.00 22679.00 24319.00 18004.00 17537.00 [153] 20366.00 22782.00 19169.00 13807.00 29743.00 25591.00 29096.00 26482.00 [161] 22405.00 27044.00 17970.00 18730.00 19684.00 19785.00 18479.00 10698.00 [169] 31956.00 29506.00 34506.00 27165.00 26736.00 23691.00 18157.00 17328.00 [177] 18205.00 20995.00 17382.00 9367.00 26076.73 22781.85 23596.68 23398.63 [185] 20433.55 20429.91 17501.02 15430.05 16772.84 19249.19 15848.38 10959.64 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 181 End = 192 Frequency = 1 [1] 0.1225833 0.1131621 0.1213256 0.1313918 0.1219639 0.1257223 0.1160393 [8] 0.1083447 0.1173123 0.1319779 0.1168888 0.0919498 > postscript(file="/var/www/html/rcomp/tmp/1eaxh1230112458.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/2xedg1230112459.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/3x3rb1230112459.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/4jks71230112459.tab") > > system("convert tmp/1eaxh1230112458.ps tmp/1eaxh1230112458.png") > system("convert tmp/2xedg1230112459.ps tmp/2xedg1230112459.png") > > > proc.time() user system elapsed 1.926 0.359 4.782