R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(236.422 + ,250.580 + ,279.515 + ,264.417 + ,283.706 + ,281.288 + ,271.146 + ,283.944 + ,269.155 + ,270.899 + ,276.507 + ,319.957 + ,250.746 + ,247.772 + ,280.449 + ,274.925 + ,296.013 + ,287.881 + ,279.098 + ,294.763 + ,261.924 + ,291.596 + ,287.537 + ,326.201 + ,255.598 + ,253.086 + ,285.261 + ,284.747 + ,300.402 + ,288.854 + ,295.433 + ,307.256 + ,273.189 + ,287.540 + ,290.705 + ,337.006 + ,268.335 + ,259.060 + ,293.703 + ,294.262 + ,312.404 + ,301.014 + ,309.942 + ,317.079 + ,293.912 + ,304.060 + ,301.299 + ,357.634 + ,281.493 + ,282.478 + ,319.111 + ,315.223 + ,328.445 + ,321.081 + ,328.040 + ,326.362 + ,313.566 + ,319.768 + ,324.315 + ,387.243 + ,293.308 + ,295.109 + ,339.190 + ,335.678 + ,345.401 + ,351.002 + ,351.889 + ,355.773 + ,333.363 + ,336.214 + ,343.910 + ,405.788 + ,318.682 + ,314.189 + ,362.141 + ,351.811 + ,373.727 + ,366.795 + ,362.393 + ,376.006 + ,346.423 + ,349.007 + ,357.224 + ,418.473 + ,329.169 + ,323.456 + ,374.439 + ,358.806 + ,391.816 + ,376.944 + ,372.665 + ,388.357 + ,354.241 + ,368.982 + ,378.233 + ,426.699 + ,343.241 + ,344.577 + ,373.623 + ,369.688 + ,398.816 + ,379.387 + ,384.666 + ,383.879 + ,351.578 + ,350.920 + ,336.629 + ,385.504 + ,311.330 + ,300.545 + ,329.718 + ,331.023 + ,348.944 + ,345.650 + ,349.260 + ,354.597 + ,325.769 + ,339.734 + ,340.543 + ,401.585 + ,315.998 + ,312.327 + ,362.217 + ,358.067 + ,367.321 + ,360.372 + ,363.830 + ,364.525 + ,347.945 + ,357.404 + ,368.182 + ,429.343) > par3 = 'additive' > par2 = 'Triple' > par1 = '11' > 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.1092142 beta : 0 gamma: 0.1983137 Coefficients: [,1] a 367.2984164 b 0.6069552 s1 3.0668939 s2 6.8514377 s3 3.3758594 s4 7.2724807 s5 2.7874181 s6 4.4324148 s7 -0.1763975 s8 -2.2058647 s9 -0.7697912 s10 4.3944370 s11 4.9225455 > myresid <- x - fit$fitted[,'xhat'] > postscript(file="/var/wessaorg/rcomp/tmp/1z2qh1352558210.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/2u8xc1352558210.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/3qus01352558210.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/48zzf1352558210.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/5af3l1352558210.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/62h461352558210.tab") > > try(system("convert tmp/1z2qh1352558210.ps tmp/1z2qh1352558210.png",intern=TRUE)) character(0) > try(system("convert tmp/2u8xc1352558210.ps tmp/2u8xc1352558210.png",intern=TRUE)) character(0) > try(system("convert tmp/3qus01352558210.ps tmp/3qus01352558210.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.613 0.453 3.116