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(1149822 + ,1086979 + ,1276674 + ,1522522 + ,1742117 + ,1737275 + ,1979900 + ,2061036 + ,1867943 + ,1707752 + ,1298756 + ,1281814 + ,1281151 + ,1164976 + ,1454329 + ,1645288 + ,1817743 + ,1895785 + ,2236311 + ,2295951 + ,2087315 + ,1980891 + ,1465446 + ,1445026 + ,1488120 + ,1338333 + ,1715789 + ,1806090 + ,2083316 + ,2092278 + ,2430800 + ,2424894 + ,2299016 + ,2130688 + ,1652221 + ,1608162 + ,1647074 + ,1479691 + ,1884978 + ,2007898 + ,2208954 + ,2217164 + ,2534291 + ,2560312 + ,2429069 + ,2315077 + ,1799608 + ,1772590 + ,1744799 + ,1659093 + ,2099821 + ,2135736 + ,2427894 + ,2468882 + ,2703217 + ,2766841 + ,2655236 + ,2550373 + ,2052097 + ,1998055 + ,1920748 + ,1876694 + ,2380930 + ,2467402 + ,2770771 + ,2781340 + ,3143926 + ,3172235 + ,2952540 + ,2920877 + ,2384552 + ,2248987 + ,2208616 + ,2178756 + ,2632870 + ,2706905 + ,3029745 + ,3015402 + ,3391414 + ,3507805 + ,3177852 + ,3142961 + ,2545815 + ,2414007 + ,2372578 + ,2332664 + ,2825328 + ,2901478 + ,3263955 + ,3226738 + ,3610786 + ,3709274 + ,3467185 + ,3449646 + ,2802951 + ,2462530 + ,2490645 + ,2561520 + ,3067554 + ,3226951 + ,3546493 + ,3492787 + ,3952263 + ,3932072 + ,3720284 + ,3651555 + ,2914972 + ,2713514 + ,2703997 + ,2591373 + ,3163748 + ,3355137 + ,3613702 + ,3686773 + ,4098716 + ,4063517 + ,3551489 + ,3226663 + ,2656842 + ,2597484 + ,2572399 + ,2596631 + ,3165225 + ,3303145 + ,3698247 + ,3668631 + ,4130433 + ,4131400 + ,3864358 + ,3721110 + ,2892532 + ,2843451 + ,2747502 + ,2668775 + ,3018602 + ,3013392 + ,3393657 + ,3544233 + ,4075832 + ,4032923 + ,3734509 + ,3761285 + ,2970090 + ,2847849 + ,2741680 + ,2830639 + ,3257673 + ,3480085 + ,3843271 + ,3796961 + ,4337767 + ,4243630 + ,3927202 + ,3915296 + ,3087396 + ,2963792 + ,2955792 + ,2829925 + ,3281195 + ,3548011 + ,4059648 + ,3941175 + ,4528594 + ,4433151 + ,4145737 + ,4077132 + ,3198519 + ,3078660 + ,3028202 + ,2858642 + ,3398954 + ,3808883 + ,4175961 + ,4227542 + ,4744616 + ,4608012 + ,4295049 + ,4201144 + ,3353276 + ,3286851 + ,3169889 + ,3051720 + ,3695426 + ,3905501 + ,4296458 + ,4246247 + ,4921849 + ,4821446 + ,4425064 + ,4379099 + ,3472889 + ,3359160 + ,3200944 + ,3153170 + ,3741498 + ,3918719 + ,4403449 + ,4400407 + ,4847473 + ,4716136 + ,4297440 + ,4272253 + ,3271834 + ,3168388 + ,2911748 + ,2720999 + ,3199918 + ,3672623 + ,3892013 + ,3850845 + ,4532467 + ,4484739 + ,4014972 + ,3983758 + ,3158459 + ,3100569 + ,2935404 + ,2855719 + ,3465611 + ,3006985 + ,4095110 + ,4104793 + ,4730788 + ,4642726 + ,4246919 + ,4308117) > 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=0, beta=0) > if (par2 == 'Double') fit <- HoltWinters(x, gamma=0) > 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.4486477 beta : 0 gamma: 0.9174003 Coefficients: [,1] a 3958169.81 b 14927.79 s1 -606169.87 s2 -704531.19 s3 -898047.03 s4 -998244.23 s5 -413328.51 s6 -463001.32 s7 423883.34 s8 352705.97 s9 929669.30 s10 804168.28 s11 355424.81 s12 344316.10 > myresid <- x - fit$fitted[,'xhat'] > postscript(file="/var/wessaorg/rcomp/tmp/1py4p1322581489.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/2wzez1322581489.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/369m51322581489.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/437fq1322581489.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/5k4991322581489.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/66d9h1322581489.tab") > > try(system("convert tmp/1py4p1322581489.ps tmp/1py4p1322581489.png",intern=TRUE)) character(0) > try(system("convert tmp/2wzez1322581489.ps tmp/2wzez1322581489.png",intern=TRUE)) character(0) > try(system("convert tmp/369m51322581489.ps tmp/369m51322581489.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.688 0.217 1.908