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(413491 + ,399153 + ,385939 + ,373917 + ,364635 + ,364696 + ,418358 + ,428212 + ,423730 + ,420677 + ,417428 + ,423245 + ,423113 + ,418873 + ,405733 + ,397812 + ,389918 + ,391116 + ,443814 + ,460373 + ,455422 + ,456288 + ,452233 + ,459256 + ,461146 + ,451391 + ,443101 + ,438810 + ,430457 + ,435721 + ,488280 + ,505814 + ,502338 + ,500910 + ,501434 + ,515476 + ,520862 + ,519517 + ,511805 + ,508607 + ,505327 + ,511435 + ,570158 + ,591665 + ,593572 + ,586346 + ,586063 + ,591504 + ,594033 + ,585597 + ,572450 + ,562917 + ,554675 + ,553997 + ,601310 + ,622255 + ,616735 + ,606480 + ,595079 + ,598588 + ,599917 + ,591573 + ,575489 + ,567223 + ,555338 + ,555252 + ,608249 + ,630859 + ,628632 + ,624435 + ,609670 + ,615830 + ,621170 + ,604212 + ,584348 + ,573717 + ,555234 + ,544897 + ,598866 + ,620081 + ,607699 + ,589960 + ,578665 + ,580166 + ,579457 + ,571560 + ,560460 + ,551397 + ,536763 + ,540562 + ,588184 + ,607049 + ,598968 + ,577644 + ,562640 + ,565867 + ,561274 + ,554144 + ,539900 + ,526271 + ,511841 + ,505282 + ,554083 + ,584225 + ,568858 + ,539516 + ,521612 + ,525562 + ,526519 + ,515713 + ,503454 + ,489301 + ,479020 + ,475102 + ,523682 + ,551528 + ,531626 + ,511037 + ,492417 + ,492188 + ,492865 + ,480961 + ,461935 + ,456608 + ,441977 + ,439148 + ,488180 + ,520564 + ,501492 + ,485025 + ,464196 + ,460170 + ,467037 + ,460070 + ,447988 + ,442867 + ,436087 + ,431328 + ,484015 + ,509673 + ,512927 + ,502831 + ,470984 + ,471067 + ,476049 + ,474605 + ,470439 + ,461251 + ,454724 + ,455626 + ,516847 + ,525192 + ,522975 + ,518585 + ,509239 + ,512238 + ,519164 + ,517009 + ,509933 + ,509127 + ,500857 + ,506971 + ,569323 + ,579714 + ,577992 + ,565464 + ,547344 + ,554788 + ,562325 + ,560854 + ,555332 + ,543599 + ,536662 + ,542722 + ,593530 + ,610763 + ,612613 + ,611324 + ,594167 + ,595454 + ,590865 + ,589379 + ,584428 + ,573100 + ,567456 + ,569028 + ,620735 + ,628884 + ,628232 + ,612117 + ,595404 + ,597141 + ,593408 + ,590072 + ,579799 + ,574205 + ,572775 + ,572942 + ,619567 + ,625809 + ,619916 + ,587625 + ,565742 + ,557274 + ,560576 + ,548854 + ,531673 + ,525919 + ,511038 + ,498662 + ,555362 + ,564591 + ,541657 + ,527070 + ,509846 + ,514258 + ,516922 + ,507561 + ,492622 + ,490243 + ,469357 + ,477580 + ,528379 + ,533590 + ,517945 + ,506174 + ,501866 + ,516141 + ,528222 + ,532638 + ,536322 + ,536535 + ,523597 + ,536214 + ,586570 + ,596594 + ,580523 + ,564478 + ,557560 + ,575093 + ,580112 + ,574761 + ,563250 + ,551531 + ,537034 + ,544686 + ,600991 + ,604378 + ,586111 + ,563668 + ,548604 + ,551174 + ,555654) > par3 = 'additive' > par2 = 'Triple' > par1 = '12' > 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.6619994 beta : 0.1215102 gamma: 1 Coefficients: [,1] a 547560.322 b -1659.258 s1 -3696.812 s2 -15192.780 s3 -22323.939 s4 -34568.491 s5 -26459.298 s6 25364.085 s7 30275.550 s8 16231.489 s9 3272.346 s10 -3221.445 s11 5698.944 s12 8093.678 > myresid <- x - fit$fitted[,'xhat'] > postscript(file="/var/www/rcomp/tmp/1ddy61322561003.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/www/rcomp/tmp/277651322561003.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/www/rcomp/tmp/380fx1322561003.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/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/www/rcomp/tmp/4jgnq1322561004.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/www/rcomp/tmp/57bia1322561004.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/www/rcomp/tmp/687ld1322561004.tab") > > try(system("convert tmp/1ddy61322561003.ps tmp/1ddy61322561003.png",intern=TRUE)) character(0) > try(system("convert tmp/277651322561003.ps tmp/277651322561003.png",intern=TRUE)) character(0) > try(system("convert tmp/380fx1322561003.ps tmp/380fx1322561003.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.510 0.040 1.549