R version 2.9.0 (2009-04-17) Copyright (C) 2009 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(100.01,103.84,104.48,95.43,104.80,108.64,105.65,108.42,115.35,113.64,115.24,100.33,101.29,104.48,99.26,100.11,103.52,101.18,96.39,97.56,96.39,85.10,79.77,79.13,80.84,82.75,92.55,96.60,96.92,95.32,98.52,100.22,104.91,103.10,97.13,103.42,111.72,118.11,111.62,100.22,102.03,105.76,107.68,110.77,105.44,112.26,114.07,117.90,124.72,126.42,134.73,135.79,143.36,140.37,144.74,151.98,150.92,163.38,154.43,146.66,157.95,162.10,180.42,179.57,171.58,185.43,190.64,203.00,202.36,193.41,186.17,192.24,209.60,206.41,209.82,230.37,235.80,232.07,244.64,242.19,217.48,209.39,211.73,221.00,203.11,214.71,224.19,238.04,238.36,246.24,259.87,249.97,266.48,282.98,306.31,301.73,314.62,332.62,355.51,370.32,408.13,433.58,440.51,386.29,342.84,254.97,203.42,170.09,174.03,167.85,177.01,188.19,211.20,240.91,230.26,251.25,241.66) > par10 = 'FALSE' > par9 = '0' > par8 = '0' > par7 = '1' > par6 = '3' > par5 = '12' > par4 = '0' > par3 = '2' > 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 ma1 0.3960 -0.1278 -0.0969 -0.9808 s.e. 0.1062 0.1276 0.1284 0.0412 sigma^2 estimated as 122.4: log likelihood = -395.26, aic = 800.53 > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 106 End = 117 Frequency = 1 [1] 334.4646 344.5283 356.3659 363.1492 365.9171 367.5691 369.7825 372.7501 [9] 376.0526 379.3370 382.4982 385.5806 $se Time Series: Start = 106 End = 117 Frequency = 1 [1] 11.06650 19.18226 25.16920 29.35200 32.65942 35.66201 38.59475 41.48845 [9] 44.31371 47.05393 49.71642 52.31822 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 106 End = 117 Frequency = 1 [1] 312.7743 306.9310 307.0342 305.6192 301.9046 297.6716 294.1368 291.4327 [9] 289.1977 287.1112 285.0540 283.0369 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 106 End = 117 Frequency = 1 [1] 356.1550 382.1255 405.6975 420.6791 429.9295 437.4667 445.4283 454.0674 [9] 462.9074 471.5627 479.9424 488.1243 > 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] 100.0100 103.8400 104.4800 95.4300 104.8000 108.6400 105.6500 108.4200 [9] 115.3500 113.6400 115.2400 100.3300 101.2900 104.4800 99.2600 100.1100 [17] 103.5200 101.1800 96.3900 97.5600 96.3900 85.1000 79.7700 79.1300 [25] 80.8400 82.7500 92.5500 96.6000 96.9200 95.3200 98.5200 100.2200 [33] 104.9100 103.1000 97.1300 103.4200 111.7200 118.1100 111.6200 100.2200 [41] 102.0300 105.7600 107.6800 110.7700 105.4400 112.2600 114.0700 117.9000 [49] 124.7200 126.4200 134.7300 135.7900 143.3600 140.3700 144.7400 151.9800 [57] 150.9200 163.3800 154.4300 146.6600 157.9500 162.1000 180.4200 179.5700 [65] 171.5800 185.4300 190.6400 203.0000 202.3600 193.4100 186.1700 192.2400 [73] 209.6000 206.4100 209.8200 230.3700 235.8000 232.0700 244.6400 242.1900 [81] 217.4800 209.3900 211.7300 221.0000 203.1100 214.7100 224.1900 238.0400 [89] 238.3600 246.2400 259.8700 249.9700 266.4800 282.9800 306.3100 301.7300 [97] 314.6200 332.6200 355.5100 370.3200 408.1300 433.5800 440.5100 386.2900 [105] 342.8400 334.4646 344.5283 356.3659 363.1492 365.9171 367.5691 369.7825 [113] 372.7501 376.0526 379.3370 382.4982 385.5806 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 106 End = 117 Frequency = 1 [1] 0.03308722 0.05567688 0.07062740 0.08082629 0.08925361 0.09702122 [7] 0.10437147 0.11130368 0.11783913 0.12404258 0.12997819 0.13568687 > postscript(file="/var/www/html/rcomp/tmp/1sqp01261158612.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/2znav1261158612.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 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > 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/3ange1261158612.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/4i12x1261158612.tab") > > try(system("convert tmp/1sqp01261158612.ps tmp/1sqp01261158612.png",intern=TRUE)) character(0) > try(system("convert tmp/2znav1261158612.ps tmp/2znav1261158612.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.667 0.320 0.850