R version 2.12.0 (2010-10-15) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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 = '2' > par7 = '2' > par6 = '3' > par5 = '12' > par4 = '1' > par3 = '0' > par2 = '2.0' > par1 = '12' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2009), ARIMA Forecasting (v1.0.5) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_arimaforecasting.wasp/ > #Source of accompanying publication: > #Technical description: > 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 ma2 sar1 sar2 sma1 0.5951 -0.0360 -0.1922 -0.6130 0.0968 0.0342 0.0340 -0.9997 s.e. 0.8450 0.6476 0.1561 0.8592 0.6407 0.2367 0.2777 0.6773 sigma^2 estimated as 696389: log likelihood = -400.16, aic = 818.31 > (forecast <- predict(arima.out,par1)) $pred Time Series: Start = 61 End = 72 Frequency = 1 [1] 2863.1794 2454.1284 4021.5325 2493.9665 2629.5728 3577.1104 1609.6695 [8] 852.3171 3008.2652 3976.2697 2390.2574 3216.5247 $se Time Series: Start = 61 End = 72 Frequency = 1 [1] 911.6033 911.7384 912.8414 924.2316 928.0922 929.6427 929.6433 929.7712 [9] 929.9062 929.6904 929.6682 929.6683 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 61 End = 72 Frequency = 1 [1] 1076.4369 667.1211 2232.3634 682.4726 810.5120 1755.0107 -212.4314 [8] -970.0344 1185.6490 2154.0764 568.1077 1394.3749 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 61 End = 72 Frequency = 1 [1] 4649.922 4241.136 5810.702 4305.460 4448.634 5399.210 3431.770 2674.669 [9] 4830.881 5798.463 4212.407 5038.674 > 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 53.50869 49.53916 63.41555 49.93963 [65] 51.27936 59.80895 40.12069 29.19447 54.84765 63.05767 48.89026 56.71441 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 61 End = 72 Frequency = 1 [1] 0.1399892 0.1605084 0.1030810 0.1601564 0.1534086 0.1166160 0.2347589 [8] 0.3936084 0.1363414 0.1059119 0.1671048 0.1283661 > postscript(file="/var/www/rcomp/tmp/1ay2u1323208791.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