R version 2.6.1 (2007-11-26) Copyright (C) 2007 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(92.81,59.04,72.81,91.81,68.07,49.16,124.61,109.89,110.51,114.77,92.37,103.63,90.43,65.86,83.33,94.49,68.98,55.46,132.89,121.71,127.01,134.04,106.48,117.55,101.61,82.66,89.28,109.24,88.16,59.23,164.21,125.13,152.68,132.96,112.42,136.43,107.32,87.61,97.86,106.60,92.17,65.31,161.49,162.25,175.13,147.28,144.48,122.67,102.27,88.64,89.59,112.20,91.98,57.85,160.49,128.33,140.69,126.61,129.27,124.27,112.90,92.54,85.70,116.72,92.08,58.98,154.50,145.55,146.60,143.51,113.52,104.80) > par10 = 'TRUE' > par9 = '0' > par8 = '0' > par7 = '1' > par6 = '2' > par5 = '12' > par4 = '1' > par3 = '0' > par2 = '-0.8' > 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 ma1 0.6484 0.2882 -0.5674 s.e. 0.1906 0.1705 0.1574 sigma^2 estimated as 3.074e-06: log likelihood = 235.96, aic = -463.93 > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 61 End = 72 Frequency = 1 [1] 0.02630449 0.02865800 0.02854361 0.02391917 0.02783273 0.03984284 [7] 0.01808512 0.02141220 0.01991232 0.02155601 0.02117602 0.02179671 $se Time Series: Start = 61 End = 72 Frequency = 1 [1] 0.001753262 0.001758999 0.001857628 0.001906330 0.001958655 0.002002128 [7] 0.002041427 0.002076135 0.002107112 0.002134741 0.002159444 0.002181557 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 61 End = 72 Frequency = 1 [1] 0.02286810 0.02521036 0.02490266 0.02018276 0.02399377 0.03591867 [7] 0.01408392 0.01734297 0.01578238 0.01737191 0.01694351 0.01752086 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 61 End = 72 Frequency = 1 [1] 0.02974089 0.03210563 0.03218457 0.02765557 0.03167170 0.04376701 [7] 0.02208631 0.02548142 0.02404226 0.02574010 0.02540853 0.02607256 > 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] 92.81000 59.04000 72.81000 91.81000 68.07000 49.16000 124.61000 [8] 109.89000 110.51000 114.77000 92.37000 103.63000 90.43000 65.86000 [15] 83.33000 94.49000 68.98000 55.46000 132.89000 121.71000 127.01000 [22] 134.04000 106.48000 117.55000 101.61000 82.66000 89.28000 109.24000 [29] 88.16000 59.23000 164.21000 125.13000 152.68000 132.96000 112.42000 [36] 136.43000 107.32000 87.61000 97.86000 106.60000 92.17000 65.31000 [43] 161.49000 162.25000 175.13000 147.28000 144.48000 122.67000 102.27000 [50] 88.64000 89.59000 112.20000 91.98000 57.85000 160.49000 128.33000 [57] 140.69000 126.61000 129.27000 124.27000 94.39796 84.80915 85.23418 [64] 106.30837 87.96404 56.17747 150.78158 122.08814 133.68959 121.07085 [71] 123.79254 119.40194 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 61 End = 72 Frequency = 1 [1] 0.09757221 0.08865883 0.09488999 0.12068178 0.10400414 0.07060243 [7] 0.18721064 0.15379280 0.17202563 0.15797783 0.16400578 0.16012549 > postscript(file="/var/www/html/rcomp/tmp/1ukv51199886727.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/258pb1199886727.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 > 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/31iie1199886727.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/4eagw1199886727.tab") > > system("convert tmp/1ukv51199886727.ps tmp/1ukv51199886727.png") > system("convert tmp/258pb1199886727.ps tmp/258pb1199886727.png") > > > proc.time() user system elapsed 0.961 0.367 1.227