R version 2.12.1 (2010-12-16) 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(348542 + ,335658 + ,330664 + ,326814 + ,322900 + ,322310 + ,385164 + ,404861 + ,412136 + ,411057 + ,410040 + ,414980 + ,413626 + ,411062 + ,408352 + ,409780 + ,411318 + ,415555 + ,479481 + ,497826 + ,501638 + ,497990 + ,499287 + ,506247 + ,510401 + ,508642 + ,501805 + ,495476 + ,490336 + ,490042 + ,553155 + ,569999 + ,573170 + ,571687 + ,575453 + ,580177 + ,579849 + ,574346 + ,563325 + ,555604 + ,545544 + ,545109 + ,605181 + ,627856 + ,631421 + ,625671 + ,613577 + ,606463 + ,601676 + ,589121 + ,573559 + ,558487 + ,552148 + ,545720 + ,606569 + ,636067 + ,630704 + ,623275 + ,617771 + ,605401 + ,619393 + ,596019 + ,569977 + ,546213 + ,528492 + ,505944 + ,554910 + ,567831 + ,564021 + ,552800 + ,541102 + ,542378 + ,540380 + ,521219 + ,504652 + ,490626 + ,481686 + ,477930 + ,522605 + ,531432 + ,532355 + ,539954 + ,524987 + ,533307 + ,530541 + ,508392 + ,495208 + ,482223 + ,470495 + ,466106 + ,515037 + ,517752 + ,515565 + ,510727 + ,499725 + ,498369 + ,493756 + ,476141 + ,458458 + ,443182 + ,429597 + ,424476 + ,476257 + ,480555 + ,469762 + ,459820 + ,451028 + ,450065 + ,444385 + ,428846 + ,421020 + ,399778 + ,389005 + ,384018 + ,431933 + ,445844 + ,431464 + ,423263 + ,415881 + ,416208 + ,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) > par3 = 'additive' > par2 = 'Triple' > par1 = '12' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2010), Exponential Smoothing (v1.0.4) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_exponentialsmoothing.wasp/ > #Source of accompanying publication: > #Technical description: > 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.9285303 beta : 0.0833735 gamma: 1 Coefficients: [,1] a 584233.26458 b 56.05223 s1 13480.10373 s2 134.68688 s3 -17755.52761 s4 -30680.45509 s5 -39752.20795 s6 -38652.87960 s7 14758.63287 s8 31779.55748 s9 25872.00857 s10 15468.71102 s11 5738.64753 s12 12907.73542 > myresid <- x - fit$fitted[,'xhat'] > postscript(file="/var/www/rcomp/tmp/1pa921322562692.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/2ldqp1322562692.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/3yo561322562692.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/47tsu1322562692.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/5bo5f1322562692.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/6zp1l1322562692.tab") > > try(system("convert tmp/1pa921322562692.ps tmp/1pa921322562692.png",intern=TRUE)) character(0) > try(system("convert tmp/2ldqp1322562692.ps tmp/2ldqp1322562692.png",intern=TRUE)) character(0) > try(system("convert tmp/3yo561322562692.ps tmp/3yo561322562692.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.096 0.264 3.358