R version 2.10.1 (2009-12-14) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(93.2 + ,96 + ,95.2 + ,77.1 + ,70.9 + ,64.8 + ,70.1 + ,77.3 + ,79.5 + ,100.6 + ,100.7 + ,107.1 + ,95.9 + ,82.8 + ,83.3 + ,80 + ,80.4 + ,67.5 + ,75.7 + ,71.1 + ,89.3 + ,101.1 + ,105.2 + ,114.1 + ,96.3 + ,84.4 + ,91.2 + ,81.9 + ,80.5 + ,70.4 + ,74.8 + ,75.9 + ,86.3 + ,98.7 + ,100.9 + ,113.8 + ,89.8 + ,84.4 + ,87.2 + ,85.6 + ,72 + ,69.2 + ,77.5 + ,78.1 + ,94.3 + ,97.7 + ,100.2 + ,116.4 + ,97.1 + ,93 + ,96 + ,80.5 + ,76.1 + ,69.9 + ,73.6 + ,92.6 + ,94.2 + ,93.5 + ,108.5 + ,109.4 + ,105.1 + ,92.5 + ,97.1 + ,81.4 + ,79.1 + ,72.1 + ,78.7 + ,87.1 + ,91.4 + ,109.9 + ,116.3 + ,113 + ,100 + ,84.8 + ,94.3 + ,87.1 + ,90.3 + ,72.4 + ,84.9 + ,92.7 + ,92.2 + ,114.9 + ,112.5 + ,118.3 + ,106 + ,91.2 + ,96.6 + ,96.3 + ,88.2 + ,70.2 + ,86.5 + ,88.2 + ,102.8 + ,119.1 + ,119.2 + ,125.1 + ,106.1 + ,102.1 + ,105.2 + ,101 + ,84.3 + ,87.5 + ,92.7 + ,94.4 + ,113 + ,113.9 + ,122.9 + ,132.7 + ,106.9 + ,96.6 + ,127.3 + ,98.2 + ,100.2 + ,89.4 + ,95.3 + ,104.2 + ,106.4 + ,116.2 + ,135.9 + ,134 + ,104.6 + ,107.1 + ,123.5 + ,98.8 + ,98.6 + ,90.6 + ,89.1 + ,105.2 + ,114 + ,122.1 + ,138 + ,142.2 + ,116.4 + ,112.6 + ,123.8 + ,103.6 + ,113.9 + ,98.6 + ,95 + ,116 + ,113.9 + ,127.5 + ,131.4 + ,145.9 + ,131.5 + ,131 + ,130.5 + ,118.9 + ,114.3 + ,85.7 + ,104.6 + ,105.1 + ,117.3 + ,142.5 + ,140 + ,159.8 + ,131.2 + ,125.4 + ,126.5 + ,119.4 + ,113.5 + ,98.7 + ,114.5 + ,113.8 + ,133.1 + ,143.4 + ,137.3 + ,165.2 + ,126.9 + ,124 + ,135.7 + ,130 + ,109.4 + ,117.8 + ,120.3 + ,121 + ,132.3 + ,142.9 + ,147.4 + ,175.9 + ,132.6 + ,123.7 + ,153.3 + ,134 + ,119.6 + ,116.2 + ,118.6 + ,130.7 + ,129.3 + ,144.4 + ,163.2 + ,179.4 + ,128.1 + ,138.4 + ,152.7 + ,120 + ,140.5 + ,116.2 + ,121.4 + ,127.8 + ,143.6 + ,157.6 + ,166.2 + ,182.3 + ,153.1 + ,147.6 + ,157.7 + ,137.2 + ,151.5 + ,98.7 + ,145.8 + ,151.7 + ,129.4 + ,174.1 + ,197 + ,193.9 + ,164.1 + ,142.8 + ,157.9 + ,159.2 + ,162.2 + ,123.1 + ,130 + ,150.1 + ,169.4 + ,179.7 + ,182.1 + ,194.3 + ,161.4 + ,169.4 + ,168.8 + ,158.1 + ,158.5 + ,135.3 + ,149.3 + ,143.4 + ,142.2 + ,188.4 + ,166.2 + ,199.2 + ,182.7 + ,145.2 + ,182.1 + ,158.7 + ,141.6 + ,132.6 + ,139.6 + ,147 + ,166.6 + ,157 + ,180.4 + ,210.2 + ,159.8 + ,157.8 + ,168.2 + ,158.4 + ,152 + ,142.2 + ,137.2 + ,152.6 + ,166.8 + ,165.6 + ,198.6 + ,201.5 + ,170.7 + ,164.4 + ,179.7 + ,157 + ,168 + ,139.3 + ,138.6 + ,153.4 + ,138.9 + ,172.1 + ,198.4 + ,217.8 + ,173.7 + ,153.8 + ,175.6 + ,147.1 + ,160.3 + ,135.2 + ,148.8 + ,151 + ,148.2 + ,182.2 + ,189.2 + ,183.1 + ,170 + ,158.4 + ,176.1 + ,156.2 + ,153.2 + ,117.9 + ,149.8 + ,156.6 + ,166.7 + ,156.8 + ,158.6 + ,210.8 + ,203.6 + ,175.2 + ,168.7 + ,155.9 + ,147.3 + ,137 + ,141.1 + ,167.4 + ,160.2 + ,191.9 + ,174.4 + ,208.2 + ,159.4 + ,161.1 + ,172.1 + ,158.4 + ,114.6 + ,159.6 + ,159.7 + ,159.4 + ,160.7 + ,165.5 + ,205 + ,205.2 + ,141.6 + ,148.1 + ,184.9 + ,132.5 + ,137.3 + ,135.5 + ,121.7 + ,166.1 + ,146.8 + ,162.8 + ,186.8 + ,185.5 + ,151.5 + ,158.1 + ,143 + ,151.2 + ,147.6 + ,130.7 + ,137.5 + ,146.1 + ,133.6 + ,167.9 + ,181.9 + ,202 + ,166.5 + ,151.3 + ,146.2 + ,148.3 + ,144.7 + ,123.6 + ,151.6 + ,133.9 + ,137.4 + ,181.6 + ,182 + ,190 + ,161.2 + ,155.5 + ,141.9 + ,164.6 + ,136.2 + ,126.8 + ,152.5 + ,126.6 + ,150.1 + ,186.3 + ,147.5 + ,200.4 + ,177.2 + ,127.4 + ,177.1 + ,154.4 + ,135.2 + ,126.4 + ,147.3 + ,140.6 + ,152.3 + ,151.2 + ,172.2 + ,215.3 + ,154.1 + ,159.3 + ,160.4 + ,151.9 + ,148.4 + ,139.6 + ,148.2 + ,153.5 + ,145.1 + ,183.7 + ,210.5 + ,203.3 + ,153.3 + ,144.3 + ,169.6 + ,143.7 + ,160.1 + ,135.6 + ,141.8 + ,159.9 + ,145.7 + ,183.5 + ,198.2 + ,186.8 + ,172 + ,150.6 + ,163.3 + ,153.7 + ,152.9 + ,135.5 + ,148.5 + ,148.4 + ,133.6 + ,194.1 + ,208.6 + ,197.3 + ,164.4 + ,148.1 + ,152 + ,144.1 + ,155 + ,124.5 + ,153 + ,146 + ,138 + ,190 + ,192 + ,192 + ,147 + ,133 + ,163 + ,150 + ,129 + ,131 + ,145 + ,137 + ,138 + ,168 + ,176 + ,188 + ,139 + ,143 + ,150 + ,154 + ,137 + ,129 + ,128 + ,140 + ,143 + ,151 + ,177 + ,184 + ,151 + ,134 + ,164 + ,126 + ,131 + ,125 + ,127 + ,143 + ,143 + ,160 + ,190 + ,182 + ,138 + ,136 + ,152 + ,127 + ,151 + ,130 + ,119 + ,153) > par3 = 'multiplicative' > par2 = 'Double' > 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 without seasonal component. Call: HoltWinters(x = x, gamma = F) Smoothing parameters: alpha: 0.6920957 beta : 0.00660408 gamma: FALSE Coefficients: [,1] a 144.02420839 b 0.09031428 > myresid <- x - fit$fitted[,'xhat'] > postscript(file="/var/www/rcomp/tmp/1wz1x1275894895.ps",horizontal=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/2jnbu1275894895.ps",horizontal=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/3jnbu1275894895.ps",horizontal=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/4xx9l1275894895.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/51yp81275894895.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/6t77t1275894895.tab") > > try(system("convert tmp/1wz1x1275894895.ps tmp/1wz1x1275894895.png",intern=TRUE)) character(0) > try(system("convert tmp/2jnbu1275894895.ps tmp/2jnbu1275894895.png",intern=TRUE)) character(0) > try(system("convert tmp/3jnbu1275894895.ps tmp/3jnbu1275894895.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.100 0.840 3.175