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(102.61,102.18,101.64,102,102.18,101.89,102.09,101.6,101.33,101.44,101.49,100.41,101.38,101.4,102.16,104.46,104.75,104.2,106.05,107.54,108.23,108.99,109.51,111.99,111.08,112.95,115.49,114.67,116.85,119.57,119.41,118.46,122.81,121.76,121.37,118.61,116.08,117.84,117.02,119.78,122.58,120.98,118.92,117.81,119.73,117.16,116.03,115.55,115.36,116.09,117.32,120.45,119.86,118.51,118.92,119.11,120.34,121.23,119.43,119.28,120.64,122.24,123.1,120.72,118.34,118.8,119.29,121.47,122.35,121.53,121.72,121.58,121.55,122.02,123.74,125.8,129.29,128.89,130.04,131.57,131.97,134.43,132.63,130.26,129,131.65,134.21,138.63,138.1,140.51,144.36,145.57,148.7,147.86,143.16,141.96) > par10 = 'TRUE' > par9 = '0' > par8 = '2' > par7 = '0' > par6 = '3' > par5 = '1' > par4 = '0' > par3 = '1' > par2 = '-0.3' > 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.3463 0.1679 0.3905 0.5356 -0.4710 s.e. 0.1467 0.1553 0.1326 0.1460 0.1452 sigma^2 estimated as 8.124e-07: log likelihood = 464.06, aic = -916.12 > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 85 End = 96 Frequency = 1 [1] 0.2318665 0.2319425 0.2317930 0.2317408 0.2320114 0.2320069 0.2320006 [8] 0.2320164 0.2319747 0.2320144 0.2320290 0.2320182 $se Time Series: Start = 85 End = 96 Frequency = 1 [1] 0.0009013201 0.0014005234 0.0017199187 0.0020352827 0.0022766275 [6] 0.0025416939 0.0028159920 0.0030533441 0.0032825579 0.0034943428 [11] 0.0036942949 0.0038913419 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 85 End = 96 Frequency = 1 [1] 0.2300999 0.2291975 0.2284220 0.2277517 0.2275492 0.2270252 0.2264812 [8] 0.2260318 0.2255409 0.2251655 0.2247882 0.2243911 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 85 End = 96 Frequency = 1 [1] 0.2336331 0.2346876 0.2351640 0.2357300 0.2364735 0.2369887 0.2375199 [8] 0.2380009 0.2384085 0.2388633 0.2392698 0.2396452 > 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] 102.6100 102.1800 101.6400 102.0000 102.1800 101.8900 102.0900 101.6000 [9] 101.3300 101.4400 101.4900 100.4100 101.3800 101.4000 102.1600 104.4600 [17] 104.7500 104.2000 106.0500 107.5400 108.2300 108.9900 109.5100 111.9900 [25] 111.0800 112.9500 115.4900 114.6700 116.8500 119.5700 119.4100 118.4600 [33] 122.8100 121.7600 121.3700 118.6100 116.0800 117.8400 117.0200 119.7800 [41] 122.5800 120.9800 118.9200 117.8100 119.7300 117.1600 116.0300 115.5500 [49] 115.3600 116.0900 117.3200 120.4500 119.8600 118.5100 118.9200 119.1100 [57] 120.3400 121.2300 119.4300 119.2800 120.6400 122.2400 123.1000 120.7200 [65] 118.3400 118.8000 119.2900 121.4700 122.3500 121.5300 121.7200 121.5800 [73] 121.5500 122.0200 123.7400 125.8000 129.2900 128.8900 130.0400 131.5700 [81] 131.9700 134.4300 132.6300 130.2600 130.5791 130.4363 130.7171 130.8152 [89] 130.3074 130.3157 130.3276 130.2981 130.3761 130.3017 130.2744 130.2947 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 85 End = 96 Frequency = 1 [1] -0.01274642 -0.01962199 -0.02397387 -0.02821593 -0.03139080 -0.03488130 [7] -0.03845904 -0.04152323 -0.04446773 -0.04715300 -0.04967355 -0.05214503 > postscript(file="/var/www/html/rcomp/tmp/1wglj1197556386.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/2qtea1197556386.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/31xf31197556387.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/4nkke1197556387.tab") > > system("convert tmp/1wglj1197556386.ps tmp/1wglj1197556386.png") > system("convert tmp/2qtea1197556386.ps tmp/2qtea1197556386.png") > > > proc.time() user system elapsed 0.883 0.325 1.198