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(1038,934,988,870,854,834,872,954,870,1238,1082,1053,934,787,1081,908,995,825,822,856,887,1094,990,936,1097,918,926,907,899,971,1087,1000,1071,1190,1116,1070,1314,1068,1185,1215,1145,1251,1363,1368,1535,1853,1866,2023,1373,1968,1424,1160,1243,1375,1539,1773,1906,2076,2004) > par10 = 'FALSE' > par9 = '0' > par8 = '1' > par7 = '1' > par6 = '0' > par5 = '12' > par4 = '1' > par3 = '1' > par2 = '-1.7' > 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: ma1 sar1 -0.6051 -0.4308 s.e. 0.1601 0.1576 sigma^2 estimated as 2.100e-12: log likelihood = 407.41, aic = -808.82 > (forecast <- predict(arima.out,par1)) $pred Time Series: Start = 48 End = 59 Frequency = 1 [1] 3.760363e-06 1.666938e-06 3.901707e-06 3.188819e-06 3.187714e-06 [6] 3.593672e-06 2.588368e-06 1.541289e-06 1.977133e-06 1.128515e-06 [11] 3.143365e-08 3.062954e-07 $se Time Series: Start = 48 End = 59 Frequency = 1 [1] 1.449046e-06 1.557953e-06 1.659730e-06 1.755616e-06 1.846529e-06 [6] 1.933172e-06 2.016095e-06 2.095739e-06 2.172465e-06 2.246573e-06 [11] 2.318313e-06 2.387898e-06 > (lb <- forecast$pred - 1.96 * forecast$se) Time Series: Start = 48 End = 59 Frequency = 1 [1] 9.202330e-07 -1.386651e-06 6.486366e-07 -2.521874e-07 -4.314829e-07 [6] -1.953455e-07 -1.363178e-06 -2.566360e-06 -2.280899e-06 -3.274768e-06 [11] -4.512459e-06 -4.373985e-06 > (ub <- forecast$pred + 1.96 * forecast$se) Time Series: Start = 48 End = 59 Frequency = 1 [1] 6.600494e-06 4.720526e-06 7.154777e-06 6.629826e-06 6.806912e-06 [6] 7.382689e-06 6.539914e-06 5.648937e-06 6.235165e-06 5.531798e-06 [11] 4.575326e-06 4.986576e-06 > 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] 1038.000 934.000 988.000 870.000 854.000 834.000 872.000 [8] 954.000 870.000 1238.000 1082.000 1053.000 934.000 787.000 [15] 1081.000 908.000 995.000 825.000 822.000 856.000 887.000 [22] 1094.000 990.000 936.000 1097.000 918.000 926.000 907.000 [29] 899.000 971.000 1087.000 1000.000 1071.000 1190.000 1116.000 [36] 1070.000 1314.000 1068.000 1185.000 1215.000 1145.000 1251.000 [43] 1363.000 1368.000 1535.000 1853.000 1866.000 1552.535 2505.365 [50] 1519.200 1710.641 1710.990 1594.500 1933.995 2623.565 2266.069 [57] 3151.556 25899.846 6787.066 > (perc.se <- (ub-forecast$pred)/1.96/forecast$pred) Time Series: Start = 48 End = 59 Frequency = 1 [1] 0.6575489 NaN 0.9557762 NaN NaN NaN NaN [8] NaN NaN NaN NaN NaN > postscript(file="/var/www/html/rcomp/tmp/1at711292235574.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