R version 2.12.0 (2010-10-15) 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(9.82,9.94,9.9,9.8,9.86,10.5,10.33,10.16,9.91,9.96,10.03,9.55,9.51,9.8,10.08,10.2,10.23,10.2,10.07,10.01,10.05,9.92,10.03,10.18,10.1,10.16,10.15,10.13,10.09,10.18,10.06,9.65,9.74,9.53,9.5,9,9.15,9.32,9.62,9.59,9.37,9.35,9.32,9.49,9.52,9.59,9.35,9.2,9.57,9.78,9.79,9.57,9.53,9.65,9.36,9.4,9.32,9.31,9.19,9.39,9.28,9.28,9.31,9.28,9.31,9.35,9.19,9.07,8.96,8.69,8.58,8.56,8.47,8.46,8.75,8.95,9.33,9.51,9.561,9.94,9.9,9.275,9.56,9.779,9.746,9.991,9.98,10.195,10.31,10.25,9.871,10.06,9.894,9.59,9.64,9.89,9.53,9.388,9.16,9.418,9.57,9.857,9.877,9.76,9.76,9.695,9.475,9.262,9.097,8.55,8.16,7.532,7.325,6.749,7.13,6.995,7.346,7.73,7.837,7.514,7.58,6.83,6.617,6.715,6.63,6.891,7.002,7.09,7.36,7.477,7.826,7.79,7.578,7.204,7.198,7.685,7.795,7.46,7.274,7.33,7.655,7.767,7.84,7.424,7.54,7.351,6.735,6.777,6.679,7.34,6.978,6.92,6.628,6.385,5.984,6.268,6.596,6.395,6.715,6.804,6.929,6.846,6.992,6.774,6.75,6.485,6.27,6.47,6.78,6.71,6.141,6.72,6.68,6.371,6.097,6.27,6.447,6.37,6.446,6.54,6.374,6.33,6.63) > par3 = 'additive' > par2 = 'Double' > par1 = '5' > #'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: 1 beta : 0.03473406 gamma: FALSE Coefficients: [,1] a 6.63000000 b -0.01079641 > myresid <- x - fit$fitted[,'xhat'] > postscript(file="/var/www/rcomp/tmp/113eq1322233038.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/2yzr61322233038.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/3tutm1322233038.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/4jzzu1322233038.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/5zbn81322233038.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/6x12e1322233038.tab") > > try(system("convert tmp/113eq1322233038.ps tmp/113eq1322233038.png",intern=TRUE)) character(0) > try(system("convert tmp/2yzr61322233038.ps tmp/2yzr61322233038.png",intern=TRUE)) character(0) > try(system("convert tmp/3tutm1322233038.ps tmp/3tutm1322233038.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.780 0.070 1.831