R version 2.9.0 (2009-04-17) 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(27.951,29.781,32.914,33.488,35.652,36.488,35.387,35.676,34.844,32.447,31.068,29.010,29.812,30.951,32.974,32.936,34.012,32.946,31.948,30.599,27.691,25.073,23.406,22.248,22.896,25.317,26.558,26.471,27.543,26.198,24.725,25.005,23.462,20.780,19.815,19.761,21.454,23.899,24.939,23.580,24.562,24.696,23.785,23.812,21.917,19.713,19.282,18.788,21.453,24.482,27.474,27.264,27.349,30.632,29.429,30.084,26.290,24.379,23.335,21.346,21.106,24.514,28.353,30.805,31.348,34.556,33.855,34.787,32.529,29.998,29.257,28.155,30.466,35.704,39.327,39.351,42.234,43.630,43.722,43.121,37.985,37.135,34.646,33.026,35.087,38.846,42.013,43.908,42.868,44.423,44.167,43.636,44.382,42.142,43.452,36.912,42.413,45.344,44.873,47.510,49.554,47.369,45.998,48.140,48.441,44.928,40.454,38.661,37.246,36.843,36.424,37.594,38.144,38.737,34.560,36.080,33.508,35.462,33.374,32.110,35.533,35.532,37.903,36.763,40.399,44.164,44.496,43.110,43.880,43.930,44.327) > par3 = 'multiplicative' > par2 = 'Triple' > par1 = '12' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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 multiplicative seasonal component. Call: HoltWinters(x = x, seasonal = par3) Smoothing parameters: alpha: 0.9459286 beta : 0.03904106 gamma: 0.7743588 Coefficients: [,1] a 47.9200450 b 0.3602228 s1 0.8706880 s2 0.9095422 s3 0.9584238 s4 1.0216281 s5 1.0409518 s6 1.0912671 s7 1.0991079 s8 1.0563623 s9 1.0606158 s10 1.0218504 s11 0.9656613 s12 0.9244778 > myresid <- x - fit$fitted[,'xhat'] > postscript(file="/var/www/html/rcomp/tmp/1pn9r1293474493.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/html/rcomp/tmp/2hwqu1293474493.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/html/rcomp/tmp/3hwqu1293474493.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/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/html/rcomp/tmp/4v66k1293474493.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/html/rcomp/tmp/56f5n1293474493.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/html/rcomp/tmp/69ymt1293474493.tab") > > try(system("convert tmp/1pn9r1293474493.ps tmp/1pn9r1293474493.png",intern=TRUE)) character(0) > try(system("convert tmp/2hwqu1293474493.ps tmp/2hwqu1293474493.png",intern=TRUE)) character(0) > try(system("convert tmp/3hwqu1293474493.ps tmp/3hwqu1293474493.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.987 0.560 2.283