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(1021.3 + ,1039.79 + ,938.12 + ,947.36 + ,956.6 + ,956.6 + ,942.74 + ,951.98 + ,919.63 + ,901.15 + ,887.28 + ,836.45 + ,841.07 + ,836.45 + ,831.83 + ,817.97 + ,771.75 + ,707.05 + ,716.3 + ,725.54 + ,716.3 + ,707.05 + ,716.3 + ,780.99 + ,859.56 + ,961.22 + ,938.12 + ,988.95 + ,910.39 + ,901.15 + ,896.53 + ,910.39 + ,988.95 + ,988.95 + ,965.85 + ,975.09 + ,1002.82 + ,1025.92 + ,1081.38 + ,1164.56 + ,1201.53 + ,1229.26 + ,1275.47 + ,1275.47 + ,1307.82 + ,1252.36 + ,1261.61 + ,1340.17 + ,1414.11 + ,1409.49 + ,1432.59 + ,1520.4 + ,1529.64 + ,1455.7 + ,1427.97 + ,1538.88 + ,1612.82 + ,1635.93 + ,1603.58 + ,1589.72 + ,1557.37 + ,1589.72 + ,1668.28 + ,1635.93 + ,1615.68 + ,1644.69 + ,1622.71 + ,1626.11 + ,1705.55 + ,1841.35 + ,2029.03 + ,2024.21 + ,1952.87 + ,2153.06 + ,2339.29 + ,2502.89 + ,2515.37 + ,2445.68 + ,2491.11 + ,2691.32 + ,2651.8 + ,2593.49 + ,2697.23 + ,2751.63 + ,2713.9 + ,2747.21 + ,2982.32 + ,3063.39 + ,3058.7 + ,3074.38 + ,3341.06 + ,3500.03 + ,392.88 + ,3071.52 + ,2516.41 + ,2350.7 + ,2488.68 + ,2872.65 + ,3220.21 + ,3078.04 + ,3043.98 + ,3134.34 + ,3141.85 + ,3128.01 + ,3241.16 + ,3389.48 + ,3406.36 + ,3449.84 + ,3606.24 + ,3653.99 + ,3607.31 + ,3712.52 + ,3803.47 + ,3806.33 + ,3768.4 + ,3952.06 + ,4134.85 + ,4060.9 + ,3999.88 + ,4004.03 + ,3977.34 + ,3650.08 + ,3708.85 + ,3764.78 + ,3761.86 + ,3802.55 + ,3773.52 + ,3428.7 + ,3194.21 + ,3095.56 + ,3064.85 + ,3022.98 + ,2887.66 + ,3178.86 + ,3438.47 + ,3493.87 + ,3421.89 + ,3390.28 + ,3319.24 + ,3287.84 + ,3222.82 + ,3182.69 + ,3180.21 + ,3116.34 + ,3297.46 + ,3357.48 + ,3386.03 + ,3319.45 + ,3363.59 + ,3303.47 + ,3210.55 + ,3050.27 + ,3010.55 + ,3011.65 + ,3104.98 + ,3087.85 + ,3160.16 + ,3319.22 + ,3432.49 + ,3475.68 + ,3347.48 + ,3388.81 + ,3610.23 + ,3691.45 + ,3587.86 + ,3704.62 + ,3798.75 + ,3956.54 + ,4121.94 + ,4148.56 + ,4100.37 + ,4060.71 + ,4147.86 + ,3926.61 + ,3865.41 + ,3978.57 + ,3851.95 + ,3701.22 + ,3738.65 + ,3766.9 + ,3711.02 + ,3675.22 + ,3560.53 + ,3723.8 + ,3914.27 + ,3870.77 + ,3924.36 + ,3968.89 + ,3982.93 + ,3917.09 + ,3969.18 + ,4149.81 + ,4406.88 + ,423.82 + ,417.72 + ,4527.16 + ,4617.39 + ,4656.23 + ,4579.9 + ,4652.4 + ,4722.95 + ,4845.81 + ,4975.21 + ,5083.64 + ,5378.04 + ,5684.44 + ,5841.87 + ,5857.23 + ,6174.52 + ,6413.17 + ,6780.11 + ,6524.94 + ,6466.7 + ,6495.61 + ,6399.52 + ,6729.98 + ,7060.77 + ,7423.27 + ,8069.17 + ,8650.68 + ,8938.07 + ,9482.08 + ,10225.26 + ,9390.27 + ,8546.11 + ,8073.77 + ,8655.31 + ,9150.1 + ,9775.81 + ,9785.14 + ,9363.44 + ,9304.18 + ,9030.26 + ,8920.8 + ,8606.08 + ,8353.75 + ,8615.63 + ,8128.64 + ,8715.94 + ,8500.8 + ,8142.58 + ,7614.66 + ,7558.95 + ,7820.75 + ,7828.9 + ,7904.59 + ,8140.97 + ,8483.01 + ,8322.68 + ,8268.01 + ,8402.05 + ,8177.78 + ,7950.54 + ,8049.94 + ,7674.13 + ,7666.36 + ,7570.18 + ,7694.45 + ,7810.64 + ,7748.43 + ,7040.64 + ,7077.26 + ,7245.51 + ,7289.12 + ,7486.92 + ,7519.88 + ,7554.84 + ,7780.89 + ,7748.09 + ,7152.25 + ,6484.66 + ,6254.58 + ,5867.32 + ,5544.16 + ,5822.74 + ,5690.63 + ,5564.78 + ,5088.39 + ,4784.22 + ,5332.46 + ,5541.48 + ,5723.92 + ,5736.99 + ,5992.07 + ,6091.43 + ,6158.17 + ,6303.79 + ,6349.71 + ,6802.96 + ,7132.68 + ,7073.29 + ,7264.5 + ,7105.33 + ,7218.71 + ,7225.72 + ,7354.25 + ,7745.46 + ,8070.26 + ,8366.33 + ,8667.51 + ,8854.34 + ,9218.1 + ,9332.9 + ,9358.31 + ,9248.66 + ,9401.2 + ,9652.04 + ,9957.38 + ,10110.63 + ,10169.26 + ,10343.78 + ,10750.21 + ,11337.5 + ,11786.96 + ,12083.04 + ,12007.74 + ,11745.93 + ,11051.51 + ,11445.9 + ,11924.88 + ,12247.63 + ,12690.91 + ,12910.7 + ,13202.12 + ,13654.67 + ,13862.82 + ,13523.93 + ,14211.17 + ,14510.35 + ,14289.23 + ,14111.82 + ,13086.59 + ,13351.54 + ,13747.69 + ,12855.61 + ,12926.93 + ,12121.95 + ,11731.65 + ,11639.51 + ,12163.78 + ,12029.53 + ,11234.18 + ,9852.13 + ,9709.04 + ,9332.75 + ,7108.6 + ,6691.49 + ,6143.05 + ,6379.15 + ,5994.58 + ,5607.94 + ,6046.13 + ,6624.96 + ,6652.54 + ,6696 + ,7315.16 + ,7907.79 + ,8066.35 + ,7939.64 + ,8068.48 + ,8186.33 + ,7975.21 + ,8357.51 + ,8463.38 + ,7937.68 + ,8034.62 + ,8056.61 + ,8176.95 + ,8441.04 + ,8697.39 + ,8665.57 + ,8625.77 + ,8718.42 + ,8822.34 + ,8597.67 + ,8782.05 + ,8661.06 + ,8265.32 + ,8072.58 + ,721.85 + ,7138.6 + ,7351.11 + ,7077 + ,7272.37 + ,7577.84) > par3 = 'additive' > par2 = 'Single' > par1 = '12' > par3 <- 'additive' > par2 <- 'Single' > 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 without trend and without seasonal component. Call: HoltWinters(x = x, beta = F, gamma = F) Smoothing parameters: alpha: 0.6768206 beta : FALSE gamma: FALSE Coefficients: [,1] a 7451.521 > myresid <- x - fit$fitted[,'xhat'] > postscript(file="/var/wessaorg/rcomp/tmp/1qvsb1355692342.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/2wfkj1355692342.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/3paav1355692342.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/4f4ae1355692342.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/5dadg1355692343.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/6cuox1355692343.tab") > > try(system("convert tmp/1qvsb1355692342.ps tmp/1qvsb1355692342.png",intern=TRUE)) character(0) > try(system("convert tmp/2wfkj1355692342.ps tmp/2wfkj1355692342.png",intern=TRUE)) character(0) > try(system("convert tmp/3paav1355692342.ps tmp/3paav1355692342.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 4.304 0.363 4.644