R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(100.00,102.04,102.51,102.71,103.00,103.39,102.32,103.88,104.65,104.46,104.65,104.36,102.71,104.55,104.76,105.72,106.20,106.50,105.14,106.50,106.69,106.50,106.50,106.39,105.43,107.18,107.37,107.46,107.66,107.37,106.30,107.85,107.95,107.85,107.66,107.76,106.69,108.92,109.22,109.02,108.62,109.02,107.76,109.60,109.80,109.41,109.60,109.60,108.15,110.18,110.27,110.87,111.25,111.15,109.99,111.83,111.73,112.31,112.12,111.73,110.27,112.71,113.38,113.57,113.77,114.15,112.99,115.03,115.03,114.84,114.75,114.84,113.32,115.92,115.84,116.49,116.90,116.99,115.74,117.73,117.17,116.83,117.08,117.23,115.25,117.98,117.97,118.56,118.42,118.51,117.25,119.08,118.85,119.41,120.43,120.87,119.31,122.24,123.14,123.39,124.46,125.33,124.17,125.48,125.35,125.15,124.31,124.14,121.81,124.62,123.93,124.29,124.16,124.02,122.00,124.58,124.06) > par10 = 'FALSE' > par9 = '0' > par8 = '0' > par7 = '0' > par6 = '0' > par5 = '12' > par4 = '1' > par3 = '1' > par2 = '-1.4' > 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") sigma^2 estimated as 5.163e-11: log likelihood = 959.05, aic = -1916.11 > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 106 End = 117 Frequency = 1 [1] 0.001146954 0.001132318 0.001126096 0.001148405 0.001107068 0.001094843 [7] 0.001091485 0.001077297 0.001065974 0.001081113 0.001064041 0.001065716 $se Time Series: Start = 106 End = 117 Frequency = 1 [1] 7.185599e-06 1.016197e-05 1.244582e-05 1.437120e-05 1.606749e-05 [6] 1.760105e-05 1.901131e-05 2.032394e-05 2.155680e-05 2.272286e-05 [11] 2.383193e-05 2.489164e-05 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 106 End = 117 Frequency = 1 [1] 0.001132870 0.001112401 0.001101703 0.001120237 0.001075575 0.001060345 [7] 0.001054223 0.001037462 0.001023723 0.001036576 0.001017330 0.001016928 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 106 End = 117 Frequency = 1 [1] 0.001161037 0.001152236 0.001150490 0.001176572 0.001138560 0.001129341 [7] 0.001128747 0.001117131 0.001108225 0.001125650 0.001110751 0.001114503 > 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] 100.0000 102.0400 102.5100 102.7100 103.0000 103.3900 102.3200 103.8800 [9] 104.6500 104.4600 104.6500 104.3600 102.7100 104.5500 104.7600 105.7200 [17] 106.2000 106.5000 105.1400 106.5000 106.6900 106.5000 106.5000 106.3900 [25] 105.4300 107.1800 107.3700 107.4600 107.6600 107.3700 106.3000 107.8500 [33] 107.9500 107.8500 107.6600 107.7600 106.6900 108.9200 109.2200 109.0200 [41] 108.6200 109.0200 107.7600 109.6000 109.8000 109.4100 109.6000 109.6000 [49] 108.1500 110.1800 110.2700 110.8700 111.2500 111.1500 109.9900 111.8300 [57] 111.7300 112.3100 112.1200 111.7300 110.2700 112.7100 113.3800 113.5700 [65] 113.7700 114.1500 112.9900 115.0300 115.0300 114.8400 114.7500 114.8400 [73] 113.3200 115.9200 115.8400 116.4900 116.9000 116.9900 115.7400 117.7300 [81] 117.1700 116.8300 117.0800 117.2300 115.2500 117.9800 117.9700 118.5600 [89] 118.4200 118.5100 117.2500 119.0800 118.8500 119.4100 120.4300 120.8700 [97] 119.3100 122.2400 123.1400 123.3900 124.4600 125.3300 124.1700 125.4800 [105] 125.3500 125.9866 127.1476 127.6490 125.8729 129.2124 130.2413 130.5274 [113] 131.7530 132.7511 131.4206 132.9233 132.7741 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 106 End = 117 Frequency = 1 [1] 0.004522588 0.006508558 0.008043927 0.009130800 0.010626279 0.011802334 [7] 0.012816980 0.013917387 0.014953753 0.015563526 0.016625177 0.017366347 > postscript(file="/var/www/html/rcomp/tmp/12lrk1260470619.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/2b7rq1260470619.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/3zdrz1260470619.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/4pjo91260470619.tab") > > system("convert tmp/12lrk1260470619.ps tmp/12lrk1260470619.png") > system("convert tmp/2b7rq1260470619.ps tmp/2b7rq1260470619.png") > > > proc.time() user system elapsed 0.567 0.305 0.668