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(6.34 + ,6.42 + ,6.55 + ,6.46 + ,6.25 + ,6.62 + ,6.77 + ,7.08 + ,7.31 + ,7.3 + ,7.19 + ,7.51 + ,7.66 + ,7.5 + ,8.02 + ,7.63 + ,7.25 + ,7.24 + ,7.16 + ,6.83 + ,6.59 + ,6.76 + ,6.43 + ,6.21 + ,5.69 + ,5.56 + ,5.55 + ,5.32 + ,5.07 + ,5.19 + ,5.18 + ,5.16 + ,4.96 + ,4.67 + ,4.54 + ,4.39 + ,4.25 + ,4.32 + ,4.55 + ,4.47 + ,4.36 + ,4.33 + ,4.32 + ,4.49 + ,4.42 + ,4.55 + ,4.56 + ,4.41 + ,4.22 + ,4.17 + ,4.05 + ,4.12 + ,4.13 + ,4.08 + ,4.01 + ,3.93 + ,3.75 + ,3.59 + ,3.55 + ,3.27 + ,3.0617 + ,3.0297 + ,3.0462 + ,2.7564 + ,2.6827 + ,2.8363 + ,3.03 + ,3.2373 + ,3.3011 + ,3.6837 + ,3.6892 + ,3.8263 + ,3.9495 + ,4.1114 + ,4.2675 + ,4.3645 + ,4.8485 + ,4.9649 + ,5.105 + ,5.2484 + ,5.2192 + ,5.2184 + ,5.1933 + ,4.8809 + ,4.5736 + ,4.5913 + ,4.4711 + ,4.4811 + ,4.5205 + ,4.3125 + ,4.3109 + ,4.1075 + ,3.77 + ,3.3694 + ,3.1979 + ,3.2981 + ,3.4832 + ,3.5936 + ,3.8156 + ,3.8602 + ,3.9627 + ,3.8688 + ,3.6448 + ,3.4404 + ,3.2364 + ,3.1259 + ,3.0174 + ,2.8716 + ,2.7045 + ,2.5036 + ,2.4112 + ,2.447 + ,2.2521 + ,2.0137 + ,2.0761 + ,2.2786 + ,2.2576 + ,2.3025 + ,2.4103 + ,2.3808 + ,2.2163 + ,2.163 + ,2.055 + ,2.1626 + ,2.2974 + ,2.4044 + ,2.361 + ,2.302 + ,2.377 + ,2.3161 + ,2.3283 + ,2.301 + ,2.3121 + ,2.31 + ,2.3348 + ,2.2651 + ,2.1933 + ,2.1028 + ,2.168 + ,2.2229 + ,2.2195 + ,2.4136 + ,2.6844 + ,2.7833 + ,2.8335 + ,2.9142 + ,3.1053 + ,3.2214 + ,3.3078 + ,3.4005 + ,3.5386 + ,3.6151 + ,3.7153 + ,3.7992 + ,3.8637 + ,3.9209 + ,4.0644 + ,4.0936 + ,4.1055 + ,4.2527 + ,4.3731 + ,4.5055 + ,4.5638 + ,4.6663 + ,4.7245 + ,4.6467 + ,4.6072 + ,4.7929 + ,4.498 + ,4.3489 + ,4.5901 + ,4.8199 + ,4.9938 + ,5.3608 + ,5.3932 + ,5.323 + ,5.3839 + ,5.2478 + ,4.3504 + ,3.452 + ,2.6216 + ,2.1354 + ,1.9089 + ,1.771 + ,1.6444 + ,1.6105 + ,1.412 + ,1.3343 + ,1.261 + ,1.2426 + ,1.2306 + ,1.2424 + ,1.2322 + ,1.2252 + ,1.2151 + ,1.2252 + ,1.2493 + ,1.2813 + ,1.3734 + ,1.421 + ,1.4205 + ,1.4954 + ,1.5405 + ,1.5261 + ,1.55 + ,1.714 + ,1.9241 + ,2.0856 + ,2.1471 + ,2.1441 + ,2.1827 + ,2.0969 + ,2.0669 + ,2.1101 + ,2.0439 + ,2.0035 + ,1.8366 + ,1.6783 + ,1.4985 + ,1.3678 + ,1.266 + ,1.219 + ,1.0608 + ,0.8766 + ,0.7398 + ,0.6501 + ,0.5879 + ,0.5493 + ,0.5753 + ,0.5942 + ,0.545 + ,0.5284 + ,0.4838 + ,0.5071 + ,0.5254 + ,0.5423 + ,0.5434 + ,0.541) > par3 = 'additive' > par2 = 'Triple' > par1 = '12' > par3 <- 'additive' > par2 <- 'Triple' > par1 <- '12' > #'GNU S' R Code compiled by R2WASP v. 1.2.327 () > #Author: root > #To cite this work: Wessa P., (2013), Exponential Smoothing (v1.0.5) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_exponentialsmoothing.wasp/ > #Source of accompanying publication: > # > par1 <- as.numeric(par1) > if (par2 == 'Single') K <- 1 > if (par2 == 'Double') K <- 2 > if (par2 == 'Triple') K <- par1 > nx <- length(x) > nxmK <- nx - K > x <- ts(x, frequency = par1) > if (par2 == 'Single') fit <- HoltWinters(x, gamma=F, beta=F) > if (par2 == 'Double') fit <- HoltWinters(x, gamma=F) > if (par2 == 'Triple') fit <- HoltWinters(x, seasonal=par3) > fit Holt-Winters exponential smoothing with trend and additive seasonal component. Call: HoltWinters(x = x, seasonal = par3) Smoothing parameters: alpha: 0.8557739 beta : 0.1100044 gamma: 1 Coefficients: [,1] a 0.61328674 b -0.01254753 s1 -0.17374251 s2 -0.22685527 s3 -0.27510958 s4 -0.22661480 s5 -0.06886037 s6 0.14040761 s7 0.26322866 s8 0.30668678 s9 0.21356996 s10 0.07687865 s11 -0.02169301 s12 -0.07228674 > myresid <- x - fit$fitted[,'xhat'] > postscript(file="/var/fisher/rcomp/tmp/1ehlp1385124656.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow=c(2,1)) > plot(fit,ylab='Observed (black) / Fitted (red)',main='Interpolation Fit of Exponential Smoothing') > plot(myresid,ylab='Residuals',main='Interpolation Prediction Errors') > par(op) > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/217uw1385124656.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > p <- predict(fit, par1, prediction.interval=TRUE) > np <- length(p[,1]) > plot(fit,p,ylab='Observed (black) / Fitted (red)',main='Extrapolation Fit of Exponential Smoothing') > dev.off() null device 1 > postscript(file="/var/fisher/rcomp/tmp/3xrs01385124656.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow = c(2,2)) > acf(as.numeric(myresid),lag.max = nx/2,main='Residual ACF') > spectrum(myresid,main='Residals Periodogram') > cpgram(myresid,main='Residal Cumulative Periodogram') > qqnorm(myresid,main='Residual Normal QQ Plot') > qqline(myresid) > par(op) > dev.off() null device 1 > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Estimated Parameters of Exponential Smoothing',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Parameter',header=TRUE) > a<-table.element(a,'Value',header=TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'alpha',header=TRUE) > a<-table.element(a,fit$alpha) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'beta',header=TRUE) > a<-table.element(a,fit$beta) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'gamma',header=TRUE) > a<-table.element(a,fit$gamma) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/fisher/rcomp/tmp/4pafk1385124656.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Interpolation Forecasts of Exponential Smoothing',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'t',header=TRUE) > a<-table.element(a,'Observed',header=TRUE) > a<-table.element(a,'Fitted',header=TRUE) > a<-table.element(a,'Residuals',header=TRUE) > a<-table.row.end(a) > for (i in 1:nxmK) { + a<-table.row.start(a) + a<-table.element(a,i+K,header=TRUE) + a<-table.element(a,x[i+K]) + a<-table.element(a,fit$fitted[i,'xhat']) + a<-table.element(a,myresid[i]) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/fisher/rcomp/tmp/50h141385124656.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Extrapolation Forecasts of Exponential Smoothing',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'t',header=TRUE) > a<-table.element(a,'Forecast',header=TRUE) > a<-table.element(a,'95% Lower Bound',header=TRUE) > a<-table.element(a,'95% Upper Bound',header=TRUE) > a<-table.row.end(a) > for (i in 1:np) { + a<-table.row.start(a) + a<-table.element(a,nx+i,header=TRUE) + a<-table.element(a,p[i,'fit']) + a<-table.element(a,p[i,'lwr']) + a<-table.element(a,p[i,'upr']) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/fisher/rcomp/tmp/6r4ct1385124656.tab") > > try(system("convert tmp/1ehlp1385124656.ps tmp/1ehlp1385124656.png",intern=TRUE)) character(0) > try(system("convert tmp/217uw1385124656.ps tmp/217uw1385124656.png",intern=TRUE)) character(0) > try(system("convert tmp/3xrs01385124656.ps tmp/3xrs01385124656.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.714 0.484 3.182