R version 2.6.0 (2007-10-03) 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(95.4,101.2,101.5,101.9,101.7,100.1,97.4,96.5,99.2,102.2,105.3,111.1,114.9,124.5,142.2,159.7,165.2,198.6,207.8,219.6,239.6,235.3,218.5,213.8,205.5,198.4,198.5,190.2,180.7,193.6,192.8,195.5,197.2,196.9,178.9,172.4,156.4,143.7,153.6,168.8,185.8,199.9,205.4,197.5,199.6,200.5,193.7,179.6,169.1,169.8,195.5,194.8,204.5,203.8,204.8,204.9,240.0,248.3,258.4,254.9) > par10 = 'FALSE' > par9 = '1' > par8 = '2' > par7 = '2' > par6 = '3' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '-0.6' > par1 = '36' > #'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 ma2 sar1 sar2 sma1 0.2290 -0.3183 0.6470 0.2602 1.0000 0.0102 -0.9999 0.0972 s.e. 0.1726 0.2177 0.1603 0.0035 0.0033 0.0135 0.0002 1.0539 sigma^2 estimated as 2.618e-10: log likelihood = 126.05, aic = -234.1 > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 25 End = 60 Frequency = 1 [1] 0.04292872 0.04515955 0.04522747 0.04533980 0.04525693 0.04461006 [7] 0.04355560 0.04318430 0.04422232 0.04534961 0.04647381 0.04841567 [13] 0.04962887 0.05238017 0.05662153 0.06005848 0.06101573 0.06589201 [19] 0.06700166 0.06832381 0.07033964 0.06994317 0.06823874 0.06774024 [25] 0.06481830 0.06261581 0.06259124 0.06251407 0.06260672 0.06330335 [31] 0.06436905 0.06475383 0.06373651 0.06260528 0.06146378 0.05951703 $se Time Series: Start = 25 End = 60 Frequency = 1 [1] 2.206703e-05 3.591446e-05 5.722244e-05 8.023858e-05 9.844014e-05 [6] 1.163360e-04 1.362682e-04 1.537538e-04 1.695737e-04 1.865755e-04 [11] 2.026570e-04 2.170706e-04 2.320951e-04 2.469967e-04 2.609427e-04 [16] 2.747887e-04 2.885779e-04 3.016201e-04 3.142682e-04 3.268524e-04 [21] 3.389495e-04 3.505844e-04 3.620932e-04 3.733050e-04 3.786857e-04 [26] 3.817666e-04 3.836221e-04 3.839835e-04 3.848978e-04 3.857821e-04 [31] 3.859301e-04 3.861774e-04 3.866128e-04 3.867287e-04 3.867998e-04 [36] 3.870193e-04 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 25 End = 60 Frequency = 1 [1] 0.04288547 0.04508916 0.04511531 0.04518253 0.04506398 0.04438204 [7] 0.04328851 0.04288294 0.04388995 0.04498393 0.04607661 0.04799022 [13] 0.04917396 0.05189606 0.05611008 0.05951990 0.06045012 0.06530083 [19] 0.06638569 0.06768318 0.06967530 0.06925603 0.06752904 0.06700856 [25] 0.06407608 0.06186755 0.06183934 0.06176146 0.06185232 0.06254721 [31] 0.06361263 0.06399693 0.06297875 0.06184730 0.06070566 0.05875847 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 25 End = 60 Frequency = 1 [1] 0.04297197 0.04522994 0.04533963 0.04549707 0.04544987 0.04483808 [7] 0.04382268 0.04348565 0.04455468 0.04571530 0.04687102 0.04884113 [13] 0.05008378 0.05286428 0.05713298 0.06059707 0.06158135 0.06648318 [19] 0.06761762 0.06896444 0.07100399 0.07063032 0.06894845 0.06847192 [25] 0.06556052 0.06336407 0.06334314 0.06326668 0.06336112 0.06405948 [31] 0.06512547 0.06551074 0.06449428 0.06336327 0.06222191 0.06027558 > 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) + } > (actandfor <- c(x[1:nx], forecast$pred)) [1] 95.40000 101.20000 101.50000 101.90000 101.70000 100.10000 97.40000 [8] 96.50000 99.20000 102.20000 105.30000 111.10000 114.90000 124.50000 [15] 142.20000 159.70000 165.20000 198.60000 207.80000 219.60000 239.60000 [22] 235.30000 218.50000 213.80000 189.99994 174.61598 174.17915 173.46053 [29] 173.99025 178.21544 185.46418 188.12951 180.82739 173.39798 166.46367 [36] 155.48555 149.20247 136.37094 119.77439 108.56989 105.74592 93.02766 [43] 90.47406 87.57494 83.43208 84.22178 87.75697 88.83595 95.61014 [50] 101.28070 101.34696 101.55557 101.30521 99.45399 96.72487 95.76883 [57] 98.33002 101.30907 104.46429 110.22107 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 25 End = 60 Frequency = 1 [1] -0.0008555819 -0.0013227160 -0.0021017394 -0.0029359436 -0.0036047325 [6] -0.0043169647 -0.0051720252 -0.0058792689 -0.0063274959 -0.0067839273 [11] -0.0071858166 -0.0073858402 -0.0077001551 -0.0077633373 -0.0075894082 [16] -0.0075353981 -0.0077862727 -0.0075388777 -0.0077226643 -0.0078745706 [21] -0.0079312759 -0.0082458975 -0.0087226871 -0.0090541662 -0.0095904988 [26] -0.0100020360 -0.0100537640 -0.0100753115 -0.0100842136 -0.0099975389 [31] -0.0098382908 -0.0097868982 -0.0099517021 -0.0101316469 -0.0103186246 [36] -0.0106564290 > postscript(file="/var/www/html/rcomp/tmp/1qlv11197122571.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/2k2nd1197122572.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] 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 > 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/3ksyp1197122572.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/4mv7i1197122572.tab") > > system("convert tmp/1qlv11197122571.ps tmp/1qlv11197122571.png") > system("convert tmp/2k2nd1197122572.ps tmp/2k2nd1197122572.png") > > > proc.time() user system elapsed 3.230 0.874 3.895