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(122.36 + ,123.33 + ,123.04 + ,124.53 + ,125.13 + ,125.85 + ,126.50 + ,126.53 + ,127.07 + ,124.55 + ,124.90 + ,124.32 + ,122.84 + ,123.31 + ,123.31 + ,124.87 + ,124.64 + ,124.73 + ,124.90 + ,124.04 + ,123.28 + ,123.86 + ,122.29 + ,124.09 + ,124.54 + ,125.65 + ,125.70 + ,125.53 + ,125.61 + ,125.55 + ,125.41 + ,127.60 + ,124.68 + ,124.41 + ,126.43 + ,126.38 + ,125.78 + ,124.70 + ,125.07 + ,125.25 + ,126.58 + ,127.13 + ,125.82 + ,123.70 + ,124.39 + ,123.70 + ,124.42 + ,121.05 + ,121.02 + ,123.23 + ,121.32 + ,120.91 + ,120.72 + ,123.31 + ,119.58 + ,119.53 + ,120.59 + ,118.63 + ,118.47 + ,111.81 + ,114.71 + ,117.34 + ,115.77 + ,118.38 + ,117.84 + ,118.83 + ,120.02 + ,116.21 + ,117.08 + ,120.20 + ,119.83 + ,118.92 + ,118.03 + ,117.71 + ,119.55 + ,116.13 + ,115.97 + ,115.99 + ,114.96 + ,116.46 + ,116.55 + ,113.05 + ,117.44 + ,118.84 + ,117.06 + ,117.54 + ,119.31 + ,118.72 + ,121.55 + ,122.61 + ,121.53 + ,123.31 + ,124.07 + ,123.59 + ,122.97 + ,123.22 + ,123.04 + ,122.96 + ,122.81 + ,122.81 + ,122.62 + ,120.82 + ,119.41 + ,121.56 + ,121.59 + ,118.50 + ,118.77 + ,118.86 + ,117.60 + ,119.90 + ,121.83 + ,121.84 + ,122.12 + ,122.12 + ,121.36 + ,119.66 + ,119.32 + ,120.36 + ,117.06 + ,117.48 + ,115.60 + ,113.86 + ,116.92 + ,117.75 + ,117.75 + ,115.31 + ,116.28 + ,115.22 + ,115.65 + ,115.11 + ,118.67 + ,118.04 + ,116.50 + ,119.78 + ,119.95 + ,120.37 + ,119.79 + ,119.43 + ,121.06 + ,121.74 + ,121.09 + ,122.97 + ,120.50 + ,117.18 + ,115.03 + ,113.36 + ,112.59 + ,111.65 + ,111.98 + ,114.87 + ,114.67 + ,114.09 + ,114.77 + ,117.05 + ,117.22 + ,113.18 + ,110.95 + ,112.14 + ,112.72 + ,110.01 + ,110.29 + ,110.74 + ,110.32 + ,105.89 + ,108.97 + ,109.34 + ,106.57 + ,99.49 + ,101.81 + ,104.29 + ,109.73 + ,105.06 + ,107.97 + ,108.13 + ,109.86 + ,108.95 + ,111.20 + ,110.69 + ,106.10 + ,105.68 + ,104.12 + ,104.71 + ,104.30 + ,103.52 + ,107.76 + ,107.80 + ,107.30 + ,108.64 + ,105.03 + ,108.30 + ,107.21 + ,109.27 + ,109.50 + ,111.68 + ,111.80 + ,111.75 + ,106.68 + ,106.37 + ,105.76 + ,109.01 + ,109.01 + ,109.01 + ,109.01 + ,107.69 + ,105.19 + ,105.48 + ,102.22 + ,100.54 + ,105.00 + ,105.44 + ,107.89 + ,108.64 + ,106.70 + ,109.10 + ,105.23 + ,108.41 + ,108.80 + ,110.39 + ,110.22 + ,110.86 + ,108.58 + ,107.70 + ,106.62 + ,109.84 + ,107.16 + ,107.26 + ,108.70 + ,109.85 + ,109.41 + ,112.36 + ,111.03 + ,110.67 + ,109.21 + ,113.58 + ,113.88 + ,114.08 + ,112.33 + ,113.92 + ,114.41 + ,114.57 + ,115.35 + ,113.13 + ,113.29 + ,112.56 + ,113.06 + ,113.46 + ,115.39 + ,116.62 + ,117.04 + ,117.42 + ,115.62 + ,115.16 + ,115.69 + ,112.85 + ,114.05 + ,112.00 + ,113.74 + ,116.26 + ,118.63 + ,116.49 + ,118.23 + ,116.83 + ,118.82 + ,114.36 + ,112.02 + ,113.24 + ,109.75 + ,110.33 + ,112.86 + ,113.04 + ,113.80 + ,110.90 + ,109.96 + ,108.69 + ,108.84 + ,108.47 + ,108.07 + ,107.94 + ,108.11 + ,108.11 + ,106.81 + ,105.58 + ,105.61 + ,106.52 + ,103.86 + ,104.60 + ,104.73 + ,105.12 + ,104.76 + ,103.85 + ,103.83 + ,103.22 + ,101.64 + ,102.13 + ,104.33 + ,104.92 + ,107.78 + ,104.49 + ,102.80 + ,102.86 + ,104.51 + ,104.73 + ,102.58 + ,99.93 + ,101.41 + ,101.05 + ,99.86 + ,101.11 + ,100.89 + ,101.09 + ,98.31 + ,98.08 + ,99.55 + ,99.62 + ,97.37 + ,98.16 + ,97.98 + ,98.15 + ,97.10 + ,97.24 + ,96.70 + ,96.64 + ,100.65 + ,96.75 + ,97.74 + ,97.92 + ,98.34 + ,93.84 + ,97.80 + ,96.20 + ,95.99 + ,95.18 + ,95.95 + ,92.23 + ,91.78 + ,92.97 + ,89.76 + ,92.88 + ,96.23 + ,95.79 + ,93.97 + ,93.90 + ,93.60 + ,93.96 + ,88.69 + ,88.57 + ,85.62 + ,86.25 + ,85.33 + ,83.33 + ,77.78 + ,78.70 + ,72.05 + ,80.75 + ,81.41 + ,82.65 + ,75.85 + ,75.70 + ,78.25 + ,77.41 + ,76.84 + ,74.25 + ,74.95 + ,68.78 + ,73.21 + ,73.26 + ,78.67 + ,75.63 + ,74.99 + ,83.87 + ,79.62 + ,80.13 + ,79.76 + ,78.20 + ,78.05 + ,79.05 + ,73.32 + ,75.17 + ,73.26 + ,73.72 + ,73.57 + ,70.60 + ,71.25 + ,74.22 + ,73.32 + ,73.01 + ,74.21 + ,75.32 + ,71.73 + ,71.94 + ,72.94 + ,72.47 + ,71.94 + ,74.30 + ,74.30) > par10 = 'FALSE' > par9 = '1' > par8 = '2' > par7 = '0' > par6 = '2' > par5 = '1' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '24' > #'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 sar1 sar2 sma1 0.1902 0.0554 0.1902 0.0554 -0.6401 s.e. 0.6814 0.0820 0.6814 0.0820 0.1445 sigma^2 estimated as 4.165: log likelihood = -789, aic = 1590.01 > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 372 End = 395 Frequency = 1 [1] 79.93892 79.55751 79.49858 79.45402 79.43973 79.43338 79.43101 79.43008 [9] 79.42973 79.42959 79.42954 79.42952 79.42951 79.42951 79.42951 79.42951 [17] 79.42951 79.42951 79.42951 79.42951 79.42951 79.42951 79.42951 79.42951 $se Time Series: Start = 372 End = 395 Frequency = 1 [1] 2.040868 2.539219 2.929843 3.230235 3.490667 3.726251 3.945245 4.151684 [9] 4.347944 4.535571 4.715683 4.889144 5.056651 5.218781 5.376023 5.528794 [17] 5.677455 5.822322 5.963671 6.101747 6.236766 6.368924 6.498394 6.625335 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 372 End = 395 Frequency = 1 [1] 75.93881 74.58064 73.75609 73.12276 72.59802 72.12993 71.69833 71.29278 [9] 70.90776 70.53987 70.18680 69.84680 69.51848 69.20070 68.89251 68.59307 [17] 68.30170 68.01776 67.74071 67.47009 67.20545 66.94642 66.69266 66.44385 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 372 End = 395 Frequency = 1 [1] 83.93902 84.53438 85.24108 85.78528 86.28143 86.73683 87.16370 87.56738 [9] 87.95170 88.31931 88.67228 89.01224 89.34055 89.65832 89.96651 90.26595 [17] 90.55732 90.84126 91.11831 91.38893 91.65357 91.91260 92.16636 92.41517 > 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] 122.36000 123.33000 123.04000 124.53000 125.13000 125.85000 126.50000 [8] 126.53000 127.07000 124.55000 124.90000 124.32000 122.84000 123.31000 [15] 123.31000 124.87000 124.64000 124.73000 124.90000 124.04000 123.28000 [22] 123.86000 122.29000 124.09000 124.54000 125.65000 125.70000 125.53000 [29] 125.61000 125.55000 125.41000 127.60000 124.68000 124.41000 126.43000 [36] 126.38000 125.78000 124.70000 125.07000 125.25000 126.58000 127.13000 [43] 125.82000 123.70000 124.39000 123.70000 124.42000 121.05000 121.02000 [50] 123.23000 121.32000 120.91000 120.72000 123.31000 119.58000 119.53000 [57] 120.59000 118.63000 118.47000 111.81000 114.71000 117.34000 115.77000 [64] 118.38000 117.84000 118.83000 120.02000 116.21000 117.08000 120.20000 [71] 119.83000 118.92000 118.03000 117.71000 119.55000 116.13000 115.97000 [78] 115.99000 114.96000 116.46000 116.55000 113.05000 117.44000 118.84000 [85] 117.06000 117.54000 119.31000 118.72000 121.55000 122.61000 121.53000 [92] 123.31000 124.07000 123.59000 122.97000 123.22000 123.04000 122.96000 [99] 122.81000 122.81000 122.62000 120.82000 119.41000 121.56000 121.59000 [106] 118.50000 118.77000 118.86000 117.60000 119.90000 121.83000 121.84000 [113] 122.12000 122.12000 121.36000 119.66000 119.32000 120.36000 117.06000 [120] 117.48000 115.60000 113.86000 116.92000 117.75000 117.75000 115.31000 [127] 116.28000 115.22000 115.65000 115.11000 118.67000 118.04000 116.50000 [134] 119.78000 119.95000 120.37000 119.79000 119.43000 121.06000 121.74000 [141] 121.09000 122.97000 120.50000 117.18000 115.03000 113.36000 112.59000 [148] 111.65000 111.98000 114.87000 114.67000 114.09000 114.77000 117.05000 [155] 117.22000 113.18000 110.95000 112.14000 112.72000 110.01000 110.29000 [162] 110.74000 110.32000 105.89000 108.97000 109.34000 106.57000 99.49000 [169] 101.81000 104.29000 109.73000 105.06000 107.97000 108.13000 109.86000 [176] 108.95000 111.20000 110.69000 106.10000 105.68000 104.12000 104.71000 [183] 104.30000 103.52000 107.76000 107.80000 107.30000 108.64000 105.03000 [190] 108.30000 107.21000 109.27000 109.50000 111.68000 111.80000 111.75000 [197] 106.68000 106.37000 105.76000 109.01000 109.01000 109.01000 109.01000 [204] 107.69000 105.19000 105.48000 102.22000 100.54000 105.00000 105.44000 [211] 107.89000 108.64000 106.70000 109.10000 105.23000 108.41000 108.80000 [218] 110.39000 110.22000 110.86000 108.58000 107.70000 106.62000 109.84000 [225] 107.16000 107.26000 108.70000 109.85000 109.41000 112.36000 111.03000 [232] 110.67000 109.21000 113.58000 113.88000 114.08000 112.33000 113.92000 [239] 114.41000 114.57000 115.35000 113.13000 113.29000 112.56000 113.06000 [246] 113.46000 115.39000 116.62000 117.04000 117.42000 115.62000 115.16000 [253] 115.69000 112.85000 114.05000 112.00000 113.74000 116.26000 118.63000 [260] 116.49000 118.23000 116.83000 118.82000 114.36000 112.02000 113.24000 [267] 109.75000 110.33000 112.86000 113.04000 113.80000 110.90000 109.96000 [274] 108.69000 108.84000 108.47000 108.07000 107.94000 108.11000 108.11000 [281] 106.81000 105.58000 105.61000 106.52000 103.86000 104.60000 104.73000 [288] 105.12000 104.76000 103.85000 103.83000 103.22000 101.64000 102.13000 [295] 104.33000 104.92000 107.78000 104.49000 102.80000 102.86000 104.51000 [302] 104.73000 102.58000 99.93000 101.41000 101.05000 99.86000 101.11000 [309] 100.89000 101.09000 98.31000 98.08000 99.55000 99.62000 97.37000 [316] 98.16000 97.98000 98.15000 97.10000 97.24000 96.70000 96.64000 [323] 100.65000 96.75000 97.74000 97.92000 98.34000 93.84000 97.80000 [330] 96.20000 95.99000 95.18000 95.95000 92.23000 91.78000 92.97000 [337] 89.76000 92.88000 96.23000 95.79000 93.97000 93.90000 93.60000 [344] 93.96000 88.69000 88.57000 85.62000 86.25000 85.33000 83.33000 [351] 77.78000 78.70000 72.05000 80.75000 81.41000 82.65000 75.85000 [358] 75.70000 78.25000 77.41000 76.84000 74.25000 74.95000 68.78000 [365] 73.21000 73.26000 78.67000 75.63000 74.99000 83.87000 79.62000 [372] 79.93892 79.55751 79.49858 79.45402 79.43973 79.43338 79.43101 [379] 79.43008 79.42973 79.42959 79.42954 79.42952 79.42951 79.42951 [386] 79.42951 79.42951 79.42951 79.42951 79.42951 79.42951 79.42951 [393] 79.42951 79.42951 79.42951 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 372 End = 395 Frequency = 1 [1] 0.02553035 0.03191677 0.03685403 0.04065540 0.04394108 0.04691039 [7] 0.04966882 0.05226841 0.05473950 0.05710178 0.05936939 0.06155324 [13] 0.06366211 0.06570330 0.06768294 0.06960629 0.07147791 0.07330175 [19] 0.07508131 0.07681965 0.07851951 0.08018335 0.08181335 0.08341151 > postscript(file="/var/www/html/rcomp/tmp/1ix7g1261077262.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/2ahg91261077263.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 > > #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/358ob1261077263.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/4eotl1261077263.tab") > > try(system("convert tmp/1ix7g1261077262.ps tmp/1ix7g1261077262.png",intern=TRUE)) character(0) > try(system("convert tmp/2ahg91261077263.ps tmp/2ahg91261077263.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.749 0.334 1.445