R version 2.13.0 (2011-04-13) Copyright (C) 2011 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(19.785,18.479,10.698,31.956,29.506,34.506,27.165,26.736,23.691,18.157,17.328,18.205,20.995,17.382,9.367,31.124,26.551,30.651,25.859,25.100,25.778,20.418,18.688,20.424,24.776,19.814,12.738,31.566,30.111,30.019,31.934,25.826,26.835,20.205,17.789,20.520,22.518,15.572,11.509,25.447,24.090,27.786,26.195,20.516,22.759,19.028,16.971,20.036,22.485,18.730,14.538,27.561,25.985,34.670,32.066,27.186,29.586,21.359,21.553,19.573,24.256,22.380,16.167,27.297,28.287,33.474,28.229,28.785,25.597,18.130,20.198,22.849,23.118) > par8 = 'FALSE' > par7 = '1' > par6 = '' > par5 = '1' > par4 = '' > par3 = '0' > par2 = 'periodic' > par1 = '12' > main = 'Seasonal Decomposition by Loess' > par1 <- as.numeric(par1) #seasonal period > if (par2 != 'periodic') par2 <- as.numeric(par2) #s.window > par3 <- as.numeric(par3) #s.degree > if (par4 == '') par4 <- NULL else par4 <- as.numeric(par4)#t.window > par5 <- as.numeric(par5)#t.degree > if (par6 != '') par6 <- as.numeric(par6)#l.window > par7 <- as.numeric(par7)#l.degree > if (par8 == 'FALSE') par8 <- FALSE else par9 <- TRUE #robust > nx <- length(x) > x <- ts(x,frequency=par1) > if (par6 != '') { + m <- stl(x,s.window=par2, s.degree=par3, t.window=par4, t.degre=par5, l.window=par6, l.degree=par7, robust=par8) + } else { + m <- stl(x,s.window=par2, s.degree=par3, t.window=par4, t.degre=par5, l.degree=par7, robust=par8) + } > m$time.series seasonal trend remainder Jan 1 -0.8800026 23.47841 -2.813405772 Feb 1 -4.6005301 23.42082 -0.341289493 Mar 1 -10.8207905 23.36323 -1.844440397 Apr 1 5.8254420 23.28541 2.845151956 May 1 4.0791737 23.20758 2.219245017 Jun 1 8.4829486 23.13572 2.887329276 Jul 1 5.1810609 23.06386 -1.079923873 Aug 1 2.2649832 22.99331 1.477706942 Sep 1 2.2482440 22.92276 -1.480000667 Oct 1 -3.9072658 22.73643 -0.672166807 Nov 1 -4.6996108 22.55011 -0.522497812 Dec 1 -3.1736521 22.38725 -1.008594871 Jan 2 -0.8800026 22.22439 -0.349382735 Feb 2 -4.6005301 22.20831 -0.225781840 Mar 2 -10.8207905 22.19224 -2.004448128 Apr 2 5.8254420 22.31115 2.987406395 May 2 4.0791737 22.43006 0.041761627 Jun 2 8.4829486 22.63511 -0.467057598 Jul 2 5.1810609 22.84015 -2.162214231 Aug 2 2.2649832 23.05702 -0.222001635 Sep 2 2.2482440 23.27388 0.255872535 Oct 2 -3.9072658 23.48590 0.839364829 Nov 2 -4.6996108 23.69792 -0.310307743 Dec 2 -3.1736521 23.89959 -0.301937886 Jan 3 -0.8800026 24.10126 1.554741166 Feb 3 -4.6005301 24.24412 0.170410980 Mar 3 -10.8207905 24.38698 -0.828186389 Apr 3 5.8254420 24.39982 1.340733712 May 3 4.0791737 24.41267 1.619154521 Jun 3 8.4829486 24.31715 -2.781101592 Jul 3 5.1810609 24.22163 2.531304887 Aug 3 2.2649832 23.99086 -0.429846143 Sep 3 2.2482440 23.76009 0.826664403 Oct 3 -3.9072658 23.40907 0.703198774 Nov 3 -4.6996108 23.05804 -0.569431722 Dec 3 -3.1736521 22.64331 1.050339368 Jan 4 -0.8800026 22.22858 1.169419652 Feb 4 -4.6005301 21.83750 -1.664970520 Mar 4 -10.8207905 21.44642 0.883372125 Apr 4 5.8254420 21.21531 -1.593754384 May 4 4.0791737 20.98421 -0.973380184 Jun 4 8.4829486 20.96895 -1.665894382 Jul 4 5.1810609 20.95369 0.060254011 Aug 4 2.2649832 21.14305 -2.892037776 Sep 4 2.2482440 21.33242 -0.821667988 Oct 4 -3.9072658 21.63375 1.301520003 Nov 4 -4.6996108 21.93507 -0.264456873 Dec 4 -3.1736521 22.34930 0.860355307 Jan 5 -0.8800026 22.76353 0.601476683 Feb 5 -4.6005301 23.22075 0.109778468 Mar 5 -10.8207905 23.67798 1.680813071 Apr 5 5.8254420 24.03334 -2.297780987 May 5 4.0791737 24.38870 -2.482874337 Jun 5 8.4829486 24.60035 1.586703971 Jul 5 5.1810609 24.81199 2.072944871 Aug 5 2.2649832 24.98348 -0.062460225 Sep 5 2.2482440 25.15496 2.182796254 Oct 5 -3.9072658 25.22586 0.040408947 Nov 5 -4.6996108 25.29675 0.955856774 Dec 5 -3.1736521 25.21860 -2.471948341 Jan 6 -0.8800026 25.14045 -0.004444261 Feb 6 -4.6005301 24.97954 2.000992499 Mar 6 -10.8207905 24.81863 2.169162077 Apr 6 5.8254420 24.70399 -3.232429241 May 6 4.0791737 24.58935 -0.381519850 Jun 6 8.4829486 24.53014 0.460914291 Jul 6 5.1810609 24.47093 -1.422988975 Aug 6 2.2649832 24.41417 2.105849252 Sep 6 2.2482440 24.35741 -1.008650946 Oct 6 -3.9072658 24.30506 -2.267790434 Nov 6 -4.6996108 24.25271 0.644905213 Dec 6 -3.1736521 24.21103 1.811619271 Jan 7 -0.8800026 24.16936 -0.171357475 > m$win s t l 731 19 13 > m$deg s t l 0 1 1 > m$jump s t l 74 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/wessaorg/rcomp/tmp/1nb741322579611.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(m,main=main) > dev.off() null device 1 > mylagmax <- nx/2 > postscript(file="/var/wessaorg/rcomp/tmp/25gpk1322579611.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow = c(2,2)) > acf(as.numeric(x),lag.max = mylagmax,main='Observed') > acf(as.numeric(m$time.series[,'trend']),na.action=na.pass,lag.max = mylagmax,main='Trend') > acf(as.numeric(m$time.series[,'seasonal']),na.action=na.pass,lag.max = mylagmax,main='Seasonal') > acf(as.numeric(m$time.series[,'remainder']),na.action=na.pass,lag.max = mylagmax,main='Remainder') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/3m9jk1322579611.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow = c(2,2)) > spectrum(as.numeric(x),main='Observed') > spectrum(as.numeric(m$time.series[!is.na(m$time.series[,'trend']),'trend']),main='Trend') > spectrum(as.numeric(m$time.series[!is.na(m$time.series[,'seasonal']),'seasonal']),main='Seasonal') > spectrum(as.numeric(m$time.series[!is.na(m$time.series[,'remainder']),'remainder']),main='Remainder') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/431031322579611.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow = c(2,2)) > cpgram(as.numeric(x),main='Observed') > cpgram(as.numeric(m$time.series[!is.na(m$time.series[,'trend']),'trend']),main='Trend') > cpgram(as.numeric(m$time.series[!is.na(m$time.series[,'seasonal']),'seasonal']),main='Seasonal') > cpgram(as.numeric(m$time.series[!is.na(m$time.series[,'remainder']),'remainder']),main='Remainder') > 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,'Seasonal Decomposition by Loess - Parameters',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Component',header=TRUE) > a<-table.element(a,'Window',header=TRUE) > a<-table.element(a,'Degree',header=TRUE) > a<-table.element(a,'Jump',header=TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Seasonal',header=TRUE) > a<-table.element(a,m$win['s']) > a<-table.element(a,m$deg['s']) > a<-table.element(a,m$jump['s']) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Trend',header=TRUE) > a<-table.element(a,m$win['t']) > a<-table.element(a,m$deg['t']) > a<-table.element(a,m$jump['t']) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Low-pass',header=TRUE) > a<-table.element(a,m$win['l']) > a<-table.element(a,m$deg['l']) > a<-table.element(a,m$jump['l']) > a<-table.row.end(a) > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/55jwu1322579611.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Seasonal Decomposition by Loess - Time Series Components',6,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,'Seasonal',header=TRUE) > a<-table.element(a,'Trend',header=TRUE) > a<-table.element(a,'Remainder',header=TRUE) > a<-table.row.end(a) > for (i in 1:nx) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,x[i]) + a<-table.element(a,x[i]+m$time.series[i,'remainder']) + a<-table.element(a,m$time.series[i,'seasonal']) + a<-table.element(a,m$time.series[i,'trend']) + a<-table.element(a,m$time.series[i,'remainder']) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/6s89e1322579611.tab") > > try(system("convert tmp/1nb741322579611.ps tmp/1nb741322579611.png",intern=TRUE)) character(0) > try(system("convert tmp/25gpk1322579611.ps tmp/25gpk1322579611.png",intern=TRUE)) character(0) > try(system("convert tmp/3m9jk1322579611.ps tmp/3m9jk1322579611.png",intern=TRUE)) character(0) > try(system("convert tmp/431031322579611.ps tmp/431031322579611.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.363 0.303 1.688