R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch" Copyright (C) 2016 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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. Natural language support but running in an English locale 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. > source('/home/pw/wessanet/cretab') > > > > myrfcuid = 'r0619023' > > x <- c(1100,680,860,440,1480,1620,1240,1440,1540,860,1180,1180,1480,940,1300,860,1220,2180,940,920,2060,1160,980,1020,740,720,1340,1140,1200,1900,1020,2140,2020,1340,1400,2320,1280,1160,2120,1540,2400,1420,1480,3380,1880,2200,1980,1340,1960,1340,3300,1780,2040,4460,800,1420,1960,1940,1880,940,1880,720,1660,4260,2540,2320,2860,5880,3140,4440,3600,2920,2260,3740,3380,4560,3320,4760,4000,4840,6160,3440,3280,2000,3600,4320,3480,5620,4200,8540,3800,5380,5140,2720,3120,3440,5020,5800,2260,5800,5660,4880,3440,5900,5960,5520,5920,3840) > par4 = '12' > par3 = 'additive' > par2 = 'Double' > par1 = '12' > par4 <- '12' > par3 <- 'additive' > par2 <- 'Double' > par1 <- '12' > #'GNU S' R Code compiled by R2WASP v. 1.2.327 (Sun, 13 Nov 2016 17:42:22 +0100) > #Author: root > #To cite this work: Wessa P., (2016), Exponential Smoothing (v1.0.6) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_exponentialsmoothing.wasp/ > #Source of accompanying publication: > # > par1 <- as.numeric(par1) > par4 <- as.numeric(par4) > 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.2898885 beta : 0.1144395 gamma: FALSE Coefficients: [,1] a 5163.14173 b 40.17137 > myresid <- x - fit$fitted[,'xhat'] > postscript(file="/home/pw/wessanet/rcomp/tmp/1w76r1481900304.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="/home/pw/wessanet/rcomp/tmp/2jq9k1481900304.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > p <- predict(fit, par4, 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="/home/pw/wessanet/rcomp/tmp/3pu4l1481900304.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 > > 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="/home/pw/wessanet/rcomp/tmp/4pc8j1481900304.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="/home/pw/wessanet/rcomp/tmp/51aye1481900304.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="/home/pw/wessanet/rcomp/tmp/6uuja1481900304.tab") > > try(system("convert /home/pw/wessanet/rcomp/tmp/1w76r1481900304.ps /home/pw/wessanet/rcomp/tmp/1w76r1481900304.png",intern=TRUE)) character(0) > try(system("convert /home/pw/wessanet/rcomp/tmp/2jq9k1481900304.ps /home/pw/wessanet/rcomp/tmp/2jq9k1481900304.png",intern=TRUE)) character(0) > try(system("convert /home/pw/wessanet/rcomp/tmp/3pu4l1481900304.ps /home/pw/wessanet/rcomp/tmp/3pu4l1481900304.png",intern=TRUE)) character(0) > > proc.time() user system elapsed 1.364 0.248 1.576