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(96.8,91.2,97.1,104.9,110.9,104.8,94.1,95.8,99.3,101.1,104.0,99.0,105.4,107.1,110.7,117.1,118.7,126.5,127.5,134.6,131.8,135.9,142.7,141.7,153.4,145.0,137.7,148.3,152.2,169.4,168.6,161.1,174.1,179.0,190.6,190.0,181.6,174.8,180.5,196.8,193.8,197.0,216.3,221.4,217.9,229.7,227.4,204.2,196.6,198.8,207.5,190.7,201.6,210.5,223.5,223.8,231.2,244.0,234.7,250.2) > par10 = 'FALSE' > par9 = '1' > par8 = '2' > par7 = '2' > par6 = '3' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '0.7' > 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.0318 -0.7426 -0.2177 0.2131 0.9641 0.0009 0.9987 -0.1696 s.e. 0.2297 0.3766 0.2227 0.1658 1.1443 0.0084 0.0038 NaN sigma^2 estimated as 0.001042: log likelihood = -25.98, aic = 69.96 Warning messages: 1: In arima(x[1:nx], order = c(par6, par3, par7), seasonal = list(order = c(par8, : possible convergence problem: optim gave code=1 2: In sqrt(diag(x$var.coef)) : NaNs produced > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 25 End = 60 Frequency = 1 [1] 31.96871 30.96636 32.02248 33.38942 34.41921 33.37194 31.48956 31.79386 [9] 32.41282 32.72860 33.23464 32.36079 33.47758 33.76984 34.38667 35.46867 [17] 35.73718 37.02495 37.18665 38.33646 37.88590 38.54598 39.62750 39.46863 [25] 39.37875 38.37805 39.43335 40.79937 41.82799 40.78323 38.90351 39.20837 [33] 39.82609 40.14202 40.64837 39.77553 $se Time Series: Start = 25 End = 60 Frequency = 1 [1] 0.5465469 0.5495713 0.5522928 0.5523822 0.5520420 0.5537537 0.5564834 [8] 0.5577731 0.5577128 0.5584607 0.5606775 0.5626336 0.5635134 0.5635321 [15] 0.5643612 0.5658465 0.5668384 0.5671511 0.5676629 0.5687890 0.5699317 [22] 0.5705749 0.5710546 0.5718933 1.1062773 1.1101449 1.1134436 1.1142462 [29] 1.1148771 1.1175232 1.1209646 1.1229280 1.1237102 1.1253817 1.1284052 [36] 1.1310668 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 25 End = 60 Frequency = 1 [1] 30.89748 29.88920 30.93999 32.30675 33.33720 32.28658 30.39886 30.70062 [9] 31.31971 31.63401 32.13572 31.25802 32.37309 32.66531 33.28052 34.35961 [17] 34.62618 35.91334 36.07403 37.22164 36.76884 37.42766 38.50823 38.34772 [25] 37.21045 36.20217 37.25100 38.61545 39.64283 38.59288 36.70642 37.00743 [33] 37.62362 37.93627 38.43669 37.55864 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 25 End = 60 Frequency = 1 [1] 33.03995 32.04352 33.10497 34.47209 35.50121 34.45730 32.58027 32.88709 [9] 33.50594 33.82318 34.33357 33.46355 34.58206 34.87436 35.49282 36.57773 [17] 36.84819 38.13657 38.29927 39.45129 39.00297 39.66431 40.74676 40.58955 [25] 41.54706 40.55394 41.61570 42.98329 44.01315 42.97358 41.10060 41.40931 [33] 42.02857 42.34777 42.86004 41.99242 > 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] 96.8000 91.2000 97.1000 104.9000 110.9000 104.8000 94.1000 95.8000 [9] 99.3000 101.1000 104.0000 99.0000 105.4000 107.1000 110.7000 117.1000 [17] 118.7000 126.5000 127.5000 134.6000 131.8000 135.9000 142.7000 141.7000 [25] 141.1261 134.8476 141.4653 150.1703 156.8302 150.0580 138.1141 140.0247 [33] 143.9352 145.9426 149.1769 143.6052 150.7371 152.6205 156.6185 163.7058 [41] 165.4792 174.0630 175.1500 182.9376 179.8739 184.3676 191.8017 190.7042 [49] 190.0841 183.2212 190.4607 199.9556 207.1960 199.8426 186.8153 188.9102 [57] 193.1763 195.3692 198.8992 192.8260 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 25 End = 60 Frequency = 1 [1] 0.02459756 0.02554113 0.02481596 0.02379697 0.02306597 0.02386904 [7] 0.02543187 0.02524550 0.02475730 0.02454986 0.02427009 0.02501775 [13] 0.02421546 0.02400525 0.02360665 0.02294241 0.02280907 0.02202296 [19] 0.02194651 0.02132673 0.02162556 0.02127710 0.02071046 0.02082504 [25] 0.04060190 0.04182040 0.04081070 0.03945787 0.03849904 0.03959105 [31] 0.04165572 0.04140129 0.04078049 0.04051675 0.04011506 0.04110334 > postscript(file="/var/www/html/rcomp/tmp/1z6nj1197121798.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/2opgu1197121798.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/3fy3d1197121799.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/4gbzk1197121799.tab") > > system("convert tmp/1z6nj1197121798.ps tmp/1z6nj1197121798.png") > system("convert tmp/2opgu1197121798.ps tmp/2opgu1197121798.png") > > > proc.time() user system elapsed 4.524 1.328 6.033