R version 2.13.0 (2011-04-13) Copyright (C) 2011 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(276986 + ,260633 + ,291551 + ,275383 + ,275302 + ,231693 + ,238829 + ,274215 + ,277808 + ,299060 + ,286629 + ,232313 + ,294053 + ,267510 + ,309739 + ,280733 + ,287298 + ,235672 + ,256449 + ,288997 + ,290789 + ,321898 + ,291834 + ,241380 + ,295469 + ,258200 + ,306102 + ,281480 + ,283101 + ,237414 + ,274834 + ,299340 + ,300383 + ,340862 + ,318794 + ,265740 + ,322656 + ,281563 + ,323461 + ,312579 + ,310784 + ,262785 + ,273754 + ,320036 + ,310336 + ,342206 + ,320052 + ,265582 + ,326988 + ,300713 + ,346414 + ,317325 + ,326208 + ,270657 + ,278158 + ,324584 + ,321801 + ,343542 + ,354040 + ,278179 + ,330246 + ,307344 + ,375874 + ,335309 + ,339271 + ,280264 + ,293689 + ,341161 + ,345097 + ,368712 + ,369403 + ,288384 + ,340981 + ,319072 + ,374214 + ,344529 + ,337271 + ,281016 + ,282224 + ,320984 + ,325426 + ,366276 + ,380296 + ,300727 + ,359326 + ,327610 + ,383563 + ,352405 + ,329351 + ,294486 + ,333454 + ,334339 + ,358000 + ,396057 + ,386976 + ,307155 + ,363909 + ,344700 + ,397561 + ,376791 + ,337085 + ,299252 + ,323136 + ,329091 + ,346991 + ,461999 + ,436533 + ,360372 + ,415467 + ,382110 + ,432197 + ,424254 + ,386728 + ,354508 + ,375765 + ,367986 + ,402378 + ,426516 + ,433313 + ,338461 + ,416834 + ,381099 + ,445673 + ,412408 + ,393997 + ,348241 + ,380134 + ,373688 + ,393588 + ,434192 + ,430731 + ,344468 + ,411891 + ,370497 + ,437305 + ,411270 + ,385495 + ,341273 + ,384217 + ,373223 + ,415771 + ,448634 + ,454341 + ,350297 + ,419104 + ,398027 + ,456059 + ,430052 + ,399757 + ,362731 + ,384896 + ,385349 + ,432289 + ,468891 + ,442702 + ,370178 + ,439400 + ,393900 + ,468700 + ,438800 + ,430100 + ,366300 + ,391000 + ,380900 + ,431400 + ,465400 + ,471500 + ,387500 + ,446400 + ,421500 + ,504800 + ,492071 + ,421253 + ,396682 + ,428000 + ,421900 + ,465600 + ,525793 + ,499855 + ,435287 + ,479499 + ,473027 + ,554410 + ,489574 + ,462157 + ,420331) > 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.3233748 beta : 0 gamma: 0.517269 Coefficients: [,1] a 476261.816 b 1019.729 s1 -25398.858 s2 -31444.085 s3 10990.689 s4 54440.184 s5 39094.095 s6 -38974.057 s7 15349.999 s8 -7349.642 s9 64219.056 s10 21180.621 s11 -14108.357 s12 -54476.563 > myresid <- x - fit$fitted[,'xhat'] > postscript(file="/var/wessaorg/rcomp/tmp/1hjpn1322570280.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/wessaorg/rcomp/tmp/2wbrz1322570280.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/wessaorg/rcomp/tmp/30aa61322570280.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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/4jij01322570280.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/wessaorg/rcomp/tmp/5lrkk1322570280.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/wessaorg/rcomp/tmp/6fgvq1322570280.tab") > > try(system("convert tmp/1hjpn1322570280.ps tmp/1hjpn1322570280.png",intern=TRUE)) character(0) > try(system("convert tmp/2wbrz1322570280.ps tmp/2wbrz1322570280.png",intern=TRUE)) character(0) > try(system("convert tmp/30aa61322570280.ps tmp/30aa61322570280.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.557 0.158 1.727