R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-bit) 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(46,62,66,59,58,61,41,27,58,70,49,59,44,36,72,45,56,54,53,35,61,52,47,51,52,63,74,45,51,64,36,30,55,64,39,40,63,45,59,55,40,64,27,28,45,57,45,69,60,56,58,50,51,53,37,22,55,70,62,58,39,49,58,47,42,62,39,40,72,70,54,65) > par10 = 'FALSE' > par9 = '0' > par8 = '0' > par7 = '1' > par6 = '0' > par5 = '12' > par4 = '1' > par3 = '1' > par2 = '1.4' > par1 = '12' > par10 <- 'FALSE' > par9 <- '0' > par8 <- '0' > par7 <- '1' > par6 <- '0' > par5 <- '12' > par4 <- '1' > par3 <- '1' > par2 <- '1.4' > par1 <- '12' > #'GNU S' R Code compiled by R2WASP v. 1.2.327 () > #Author: root > #To cite this work: Wessa P., (2013), ARIMA Forecasting (v1.0.9) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_arimaforecasting.wasp/ > #Source of accompanying publication: > # > 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: ma1 -0.9694 s.e. 0.1058 sigma^2 estimated as 6394: log likelihood = -274, aic = 552.01 > (forecast <- predict(arima.out,par1)) $pred Time Series: Start = 61 End = 72 Frequency = 1 [1] 309.50964 281.09523 295.20444 239.98652 246.70766 260.30809 157.74763 [8] 76.64998 274.11542 383.84414 324.00688 295.20444 $se Time Series: Start = 61 End = 72 Frequency = 1 [1] 80.09285 80.13027 80.16766 80.20505 80.24241 80.27976 80.31709 80.35440 [9] 80.39169 80.42897 80.46623 80.50347 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 61 End = 72 Frequency = 1 [1] 152.5276527 124.0399123 138.0758185 82.7846255 89.4325314 102.9597719 [7] 0.3261415 -80.8446377 116.5477048 226.2033638 166.2930694 137.4176379 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 61 End = 72 Frequency = 1 [1] 466.4916 438.1506 452.3331 397.1884 403.9828 417.6564 315.1691 234.1446 [9] 431.6831 541.4849 481.7207 452.9912 > 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] 46.00000 62.00000 66.00000 59.00000 58.00000 61.00000 41.00000 27.00000 [9] 58.00000 70.00000 49.00000 59.00000 44.00000 36.00000 72.00000 45.00000 [17] 56.00000 54.00000 53.00000 35.00000 61.00000 52.00000 47.00000 51.00000 [25] 52.00000 63.00000 74.00000 45.00000 51.00000 64.00000 36.00000 30.00000 [33] 55.00000 64.00000 39.00000 40.00000 63.00000 45.00000 59.00000 55.00000 [41] 40.00000 64.00000 27.00000 28.00000 45.00000 57.00000 45.00000 69.00000 [49] 60.00000 56.00000 58.00000 50.00000 51.00000 53.00000 37.00000 22.00000 [57] 55.00000 70.00000 62.00000 58.00000 60.12471 56.12819 58.12641 50.13413 [65] 51.13307 53.13104 37.15125 22.18605 55.12912 70.11726 62.12309 58.12641 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 61 End = 72 Frequency = 1 [1] 0.1737201 0.1903420 0.1818283 0.2209966 0.2154503 0.2049659 0.3262546 [8] 0.6225942 0.1955017 0.1421459 0.1670837 0.1825474 > postscript(file="/var/fisher/rcomp/tmp/1sfp81385824714.ps",horizontal=F,onefile=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)) Error in plot.window(...) : need finite 'ylim' values Calls: plot -> plot.default -> localWindow -> plot.window Execution halted