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(105.6,97.4,0.9,0,-2.5,4,1,-3.8,5.4,-2.3,1,-0.5,-1.8,3.4,11.1,6,8.3,6.7,-2.2,5.9,8,6.7,15.5,7.9,8.9,21.1,-10,0.3,7.8,0.2,4,15.8,2.6,6.6,4.5,-3.8,6.8,6.8,8.1,1.2,-0.6,3.8,7.7,-5.5,-10,-1.1,-1.1,-3.9,0.3,-12.5,2.3,6.9,10.8,-2.2,8.2,3.8,4.1,5.1,0.7,12.4,6,3.3,-111,-112.4,-130.6,-109.1,-118.8,-123.9,-101.6,-112.8,-128,-129.6) > par10 = 'FALSE' > par9 = '0' > par8 = '2' > par7 = '0' > par6 = '3' > par5 = '12' > par4 = '1' > par3 = '0' > par2 = '1' > 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 sar1 sar2 0.8710 -0.1345 -0.0708 -0.6115 -0.0655 s.e. 0.1559 0.2649 0.2573 0.2214 0.2185 sigma^2 estimated as 259.8: log likelihood = -204.43, aic = 420.87 > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 61 End = 72 Frequency = 1 [1] 18.0991761 10.2461694 10.4393610 6.0733247 5.2604911 1.2260664 [7] 7.3343826 -0.8290815 -3.9478963 1.6623780 -0.1073540 2.4124759 $se Time Series: Start = 61 End = 72 Frequency = 1 [1] 16.11749 21.37411 23.62315 24.30871 24.45224 24.46601 24.46606 24.46840 [9] 24.47086 24.47217 24.47263 24.47273 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 61 End = 72 Frequency = 1 [1] -13.49111 -31.64709 -35.86201 -41.57175 -42.66590 -46.72731 -40.61909 [8] -48.78715 -51.91078 -46.30307 -48.07371 -45.55408 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 61 End = 72 Frequency = 1 [1] 49.68946 52.13943 56.74074 53.71840 53.18689 49.17945 55.28785 47.12898 [9] 44.01499 49.62783 47.85900 50.37904 > 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] 105.6000000 97.4000000 0.9000000 0.0000000 -2.5000000 4.0000000 [7] 1.0000000 -3.8000000 5.4000000 -2.3000000 1.0000000 -0.5000000 [13] -1.8000000 3.4000000 11.1000000 6.0000000 8.3000000 6.7000000 [19] -2.2000000 5.9000000 8.0000000 6.7000000 15.5000000 7.9000000 [25] 8.9000000 21.1000000 -10.0000000 0.3000000 7.8000000 0.2000000 [31] 4.0000000 15.8000000 2.6000000 6.6000000 4.5000000 -3.8000000 [37] 6.8000000 6.8000000 8.1000000 1.2000000 -0.6000000 3.8000000 [43] 7.7000000 -5.5000000 -10.0000000 -1.1000000 -1.1000000 -3.9000000 [49] 0.3000000 -12.5000000 2.3000000 6.9000000 10.8000000 -2.2000000 [55] 8.2000000 3.8000000 4.1000000 5.1000000 0.7000000 12.4000000 [61] 18.0991761 10.2461694 10.4393610 6.0733247 5.2604911 1.2260664 [67] 7.3343826 -0.8290815 -3.9478963 1.6623780 -0.1073540 2.4124759 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 61 End = 72 Frequency = 1 [1] 0.8905098 2.0860587 2.2628924 4.0025378 4.6482814 [6] 19.9548824 3.3358031 -29.5126592 -6.1984555 14.7211821 [11] -227.9620177 10.1442402 > postscript(file="/var/www/html/rcomp/tmp/18x9i1197305487.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/2rybo1197305487.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/33nxs1197305487.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/4oxgw1197305487.tab") > > system("convert tmp/18x9i1197305487.ps tmp/18x9i1197305487.png") > system("convert tmp/2rybo1197305487.ps tmp/2rybo1197305487.png") > > > proc.time() user system elapsed 1.725 0.364 1.875