R version 2.8.0 (2008-10-20) Copyright (C) 2008 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(41130 + ,43144 + ,46195 + ,40033 + ,31710 + ,42297 + ,33889 + ,23495 + ,27060 + ,31160 + ,22214 + ,16905 + ,34388 + ,29982 + ,36374 + ,37630 + ,31023 + ,39875 + ,28866 + ,20205 + ,26082 + ,28209 + ,22813 + ,15296 + ,27796 + ,31813 + ,42513 + ,41222 + ,29094 + ,28948 + ,23230 + ,21308 + ,20649 + ,23666 + ,19206 + ,16361 + ,30472 + ,25051 + ,39393 + ,32091 + ,31007 + ,32998 + ,22809 + ,20439 + ,19900 + ,29161 + ,22149 + ,15485 + ,36181 + ,39545 + ,37955 + ,31854 + ,29788 + ,31435 + ,22504 + ,19540 + ,21893 + ,29556 + ,21811 + ,13729 + ,31332 + ,31434 + ,38812 + ,36154 + ,32820 + ,32301 + ,30358 + ,20724 + ,21056 + ,30077 + ,22411 + ,16758 + ,37243 + ,41795 + ,37755 + ,42557 + ,21507 + ,43211 + ,31476 + ,21440 + ,25307 + ,34050 + ,21970 + ,17327 + ,33607 + ,34259 + ,43309 + ,40189 + ,32663 + ,36262 + ,35718 + ,25002 + ,28764 + ,33085 + ,25403 + ,17468 + ,39457 + ,39408 + ,49419 + ,37128 + ,34698 + ,40939 + ,32695 + ,27523 + ,26875 + ,28460 + ,26511 + ,19576 + ,40659 + ,35685 + ,44559 + ,37584 + ,34670 + ,42953 + ,24058 + ,35359 + ,30919 + ,35346 + ,28309 + ,17417 + ,45465 + ,44651 + ,47947 + ,43458 + ,37744 + ,39730 + ,29903 + ,24284 + ,37981 + ,32001 + ,32273 + ,23314 + ,43522 + ,33000 + ,43685 + ,45838 + ,39741 + ,42522 + ,37318 + ,26920 + ,28651 + ,35646 + ,26312 + ,20442 + ,46402 + ,45329 + ,42185 + ,49341 + ,50472 + ,33020 + ,29567 + ,22870 + ,25730 + ,32609 + ,23536 + ,15135 + ,36776 + ,29982 + ,38062 + ,34226 + ,24906 + ,30233 + ,27405 + ,20784 + ,22886 + ,25425 + ,20838 + ,15655 + ,37158 + ,36364 + ,43213 + ,31635 + ,30113 + ,29985 + ,20919 + ,19429 + ,21427 + ,26064 + ,20109 + ,15369 + ,35466 + ,25954 + ,33504 + ,28115 + ,28501 + ,28618 + ,21434 + ,20177 + ,21484 + ,25642 + ,23515 + ,12941 + ,36190 + ,37785 + ,38407 + ,33326 + ,30304 + ,27576 + ,27048 + ,17291 + ,21018 + ,26792 + ,19426 + ,13927 + ,35647 + ,31746 + ,31277 + ,31583 + ,25607 + ,28151 + ,24947 + ,18077 + ,23429 + ,26313 + ,18862 + ,14753 + ,36409 + ,33163 + ,34122 + ,35225 + ,28249 + ,30374 + ,26311 + ,22069 + ,23651 + ,28628 + ,23187 + ,14727 + ,43080 + ,32519 + ,39657 + ,33614 + ,28671 + ,34243 + ,27336 + ,22916 + ,24537 + ,26128 + ,22602 + ,15744 + ,41086 + ,39690 + ,43129 + ,37863 + ,35953 + ,29133 + ,24693 + ,22205 + ,21725 + ,27192 + ,21790 + ,13253 + ,37702 + ,30364 + ,32609 + ,30212 + ,29965 + ,28352 + ,25814 + ,22414 + ,20506 + ,28806 + ,22228 + ,13971 + ,36845 + ,35338 + ,35022 + ,34777 + ,26887 + ,23970 + ,22780 + ,17351 + ,21382 + ,24561 + ,17409 + ,11514 + ,31514 + ,27071 + ,29462 + ,26105 + ,22397 + ,23843 + ,21705 + ,18089 + ,20764 + ,25316 + ,17704 + ,15548 + ,28029 + ,29383 + ,36438 + ,32034 + ,22679 + ,24319 + ,18004 + ,17537 + ,20366 + ,22782 + ,19169 + ,13807 + ,29743 + ,25591 + ,29096 + ,26482 + ,22405 + ,27044 + ,17970 + ,18730 + ,19684 + ,19785 + ,18479 + ,10698 + ,31956 + ,29506 + ,34506 + ,27165 + ,26736 + ,23691 + ,18157 + ,17328 + ,18205 + ,20995 + ,17382 + ,9367 + ,31124 + ,26551 + ,30651 + ,25859 + ,25100 + ,25778 + ,20418 + ,18688 + ,20424 + ,24776 + ,19814 + ,12738) > par10 = 'FALSE' > par9 = '1' > par8 = '0' > par7 = '1' > par6 = '1' > par5 = '12' > par4 = '1' > par3 = '0' > par2 = '0.5' > 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 ma1 sma1 0.9851 -0.7663 -0.8841 s.e. 0.0132 0.0399 0.0346 sigma^2 estimated as 89.93: log likelihood = -1153.18, aic = 2314.36 > (forecast <- predict(arima.out,fx)) $pred Time Series: Start = 325 End = 336 Frequency = 1 [1] 172.0811 163.7929 175.0184 165.3674 152.8632 155.0568 138.5517 127.9886 [9] 134.7408 146.7992 130.0674 104.4396 $se Time Series: Start = 325 End = 336 Frequency = 1 [1] 9.484673 9.708955 9.921736 10.123926 10.316326 10.499645 10.674512 [8] 10.841490 11.001086 11.153760 11.299926 11.439965 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 325 End = 336 Frequency = 1 [1] 153.49109 144.76335 155.57176 145.52446 132.64322 134.47753 117.62965 [8] 106.73926 113.17868 124.93780 107.91957 82.01726 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 325 End = 336 Frequency = 1 [1] 190.6710 182.8225 194.4650 185.2102 173.0832 175.6361 159.4737 149.2379 [9] 156.3029 168.6605 152.2153 126.8619 > 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] 41130.00 43144.00 46195.00 40033.00 31710.00 42297.00 33889.00 23495.00 [9] 27060.00 31160.00 22214.00 16905.00 34388.00 29982.00 36374.00 37630.00 [17] 31023.00 39875.00 28866.00 20205.00 26082.00 28209.00 22813.00 15296.00 [25] 27796.00 31813.00 42513.00 41222.00 29094.00 28948.00 23230.00 21308.00 [33] 20649.00 23666.00 19206.00 16361.00 30472.00 25051.00 39393.00 32091.00 [41] 31007.00 32998.00 22809.00 20439.00 19900.00 29161.00 22149.00 15485.00 [49] 36181.00 39545.00 37955.00 31854.00 29788.00 31435.00 22504.00 19540.00 [57] 21893.00 29556.00 21811.00 13729.00 31332.00 31434.00 38812.00 36154.00 [65] 32820.00 32301.00 30358.00 20724.00 21056.00 30077.00 22411.00 16758.00 [73] 37243.00 41795.00 37755.00 42557.00 21507.00 43211.00 31476.00 21440.00 [81] 25307.00 34050.00 21970.00 17327.00 33607.00 34259.00 43309.00 40189.00 [89] 32663.00 36262.00 35718.00 25002.00 28764.00 33085.00 25403.00 17468.00 [97] 39457.00 39408.00 49419.00 37128.00 34698.00 40939.00 32695.00 27523.00 [105] 26875.00 28460.00 26511.00 19576.00 40659.00 35685.00 44559.00 37584.00 [113] 34670.00 42953.00 24058.00 35359.00 30919.00 35346.00 28309.00 17417.00 [121] 45465.00 44651.00 47947.00 43458.00 37744.00 39730.00 29903.00 24284.00 [129] 37981.00 32001.00 32273.00 23314.00 43522.00 33000.00 43685.00 45838.00 [137] 39741.00 42522.00 37318.00 26920.00 28651.00 35646.00 26312.00 20442.00 [145] 46402.00 45329.00 42185.00 49341.00 50472.00 33020.00 29567.00 22870.00 [153] 25730.00 32609.00 23536.00 15135.00 36776.00 29982.00 38062.00 34226.00 [161] 24906.00 30233.00 27405.00 20784.00 22886.00 25425.00 20838.00 15655.00 [169] 37158.00 36364.00 43213.00 31635.00 30113.00 29985.00 20919.00 19429.00 [177] 21427.00 26064.00 20109.00 15369.00 35466.00 25954.00 33504.00 28115.00 [185] 28501.00 28618.00 21434.00 20177.00 21484.00 25642.00 23515.00 12941.00 [193] 36190.00 37785.00 38407.00 33326.00 30304.00 27576.00 27048.00 17291.00 [201] 21018.00 26792.00 19426.00 13927.00 35647.00 31746.00 31277.00 31583.00 [209] 25607.00 28151.00 24947.00 18077.00 23429.00 26313.00 18862.00 14753.00 [217] 36409.00 33163.00 34122.00 35225.00 28249.00 30374.00 26311.00 22069.00 [225] 23651.00 28628.00 23187.00 14727.00 43080.00 32519.00 39657.00 33614.00 [233] 28671.00 34243.00 27336.00 22916.00 24537.00 26128.00 22602.00 15744.00 [241] 41086.00 39690.00 43129.00 37863.00 35953.00 29133.00 24693.00 22205.00 [249] 21725.00 27192.00 21790.00 13253.00 37702.00 30364.00 32609.00 30212.00 [257] 29965.00 28352.00 25814.00 22414.00 20506.00 28806.00 22228.00 13971.00 [265] 36845.00 35338.00 35022.00 34777.00 26887.00 23970.00 22780.00 17351.00 [273] 21382.00 24561.00 17409.00 11514.00 31514.00 27071.00 29462.00 26105.00 [281] 22397.00 23843.00 21705.00 18089.00 20764.00 25316.00 17704.00 15548.00 [289] 28029.00 29383.00 36438.00 32034.00 22679.00 24319.00 18004.00 17537.00 [297] 20366.00 22782.00 19169.00 13807.00 29743.00 25591.00 29096.00 26482.00 [305] 22405.00 27044.00 17970.00 18730.00 19684.00 19785.00 18479.00 10698.00 [313] 31956.00 29506.00 34506.00 27165.00 26736.00 23691.00 18157.00 17328.00 [321] 18205.00 20995.00 17382.00 9367.00 29611.89 26828.12 30631.43 27346.36 [329] 23367.16 24042.62 19196.57 16381.08 18155.09 21550.00 16917.54 10907.63 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 325 End = 336 Frequency = 1 [1] 0.1161893 0.1254383 0.1196783 0.1297877 0.1439015 0.1444168 0.1657210 [8] 0.1834768 0.1763582 0.1632744 0.1885484 0.2425900 > postscript(file="/var/www/html/rcomp/tmp/1343b1229432398.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/2po3m1229432398.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/3ouo01229432398.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/4eksb1229432398.tab") > > system("convert tmp/1343b1229432398.ps tmp/1343b1229432398.png") > system("convert tmp/2po3m1229432398.ps tmp/2po3m1229432398.png") > > > proc.time() user system elapsed 1.783 0.423 3.205