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 = '1' > par8 = '0' > par7 = '0' > par6 = '0' > par5 = '12' > par4 = '1' > par3 = '0' > par2 = '1.4' > par1 = '23' > par10 <- 'FALSE' > par9 <- '1' > par8 <- '0' > par7 <- '0' > par6 <- '0' > par5 <- '12' > par4 <- '1' > par3 <- '0' > par2 <- '1.4' > par1 <- '23' > #'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: sma1 -0.7773 s.e. 0.5008 sigma^2 estimated as 3893: log likelihood = -210.17, aic = 424.35 > (forecast <- predict(arima.out,par1)) $pred Time Series: Start = 50 End = 72 Frequency = 1 [1] 250.5486 363.3767 246.8441 242.7267 316.7695 167.0978 116.6882 267.3240 [9] 312.8173 205.2536 278.5445 269.6577 250.5486 363.3767 246.8441 242.7267 [17] 316.7695 167.0978 116.6882 267.3240 312.8173 205.2536 278.5445 $se Time Series: Start = 50 End = 72 Frequency = 1 [1] 64.26802 64.26802 64.26802 64.26802 64.26802 64.26802 64.26802 64.26802 [9] 64.26802 64.26802 64.26802 63.46938 65.75249 65.75249 65.75249 65.75249 [17] 65.75249 65.75249 65.75249 65.75249 65.75249 65.75249 65.75249 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 50 End = 72 Frequency = 1 [1] 124.583309 237.411345 120.878799 116.761361 190.804223 41.132465 [7] -9.277157 141.358636 186.851989 79.288326 152.579203 145.257725 [13] 121.673748 234.501783 117.969237 113.851799 187.894661 38.222903 [19] -12.186719 138.449074 183.942427 76.378764 149.669641 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 50 End = 72 Frequency = 1 [1] 376.5139 489.3420 372.8094 368.6920 442.7349 293.0631 242.6535 393.2893 [9] 438.7826 331.2190 404.5098 394.0577 379.4235 492.2515 375.7190 371.6016 [17] 445.6444 295.9727 245.5630 396.1988 441.6922 334.1285 407.4194 > 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 51.70045 67.42585 51.15327 50.54234 61.12872 38.71116 29.95351 [57] 54.15000 60.58297 44.83698 55.76392 54.48725 51.70045 67.42585 51.15327 [65] 50.54234 61.12872 38.71116 29.95351 54.15000 60.58297 44.83698 55.76392 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 50 End = 72 Frequency = 1 [1] 0.1722811 0.1208539 0.1747270 0.1775288 0.1378351 0.2519150 0.3505082 [8] 0.1620156 0.1394982 0.2079041 0.1558091 0.1587870 0.1760441 0.1235317 [15] 0.1785410 0.1814011 0.1408743 0.2573119 0.3578674 0.1655641 0.1425726 [22] 0.2124043 0.1592274 > postscript(file="/var/wessaorg/rcomp/tmp/193gv1385312126.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