R version 2.12.1 (2010-12-16) 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(16111,15554,15220,14807,14291,14653,17006,18032,16558,16102,15055,15484,14596,14609,13923,14226,14056,14278,16142,16509,15680,14086,13129,13086,13096,12280,11534,11135,10903,10926,13220,13581,11788,11088,10434,11061,10828,10270,10360,9899,9395,9944,12117,12474,11106,10643,10227,11273,11516,11583,11605,11414,11181,12000,14007,14582,13251,12806,12645,13869,13342,13079,12513,12331,11882,12388,14394,14635,13218,12554,12031,12429) > 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 -28.753646 15949.52 190.229556 Feb 1 -330.723341 15902.18 -17.456412 Mar 1 -650.359571 15854.84 15.524153 Apr 1 -824.444562 15803.57 -172.124747 May 1 -1125.362789 15752.30 -335.940410 Jun 1 -674.813278 15693.88 -366.062609 Jul 1 1478.402950 15635.45 -107.851524 Aug 1 2001.988842 15573.00 457.006509 Sep 1 669.074849 15510.56 378.364429 Oct 1 -6.045515 15452.77 655.279924 Nov 1 -587.165691 15394.97 247.195232 Dec 1 78.201435 15324.07 81.732637 Jan 2 -28.753646 15253.16 -628.407751 Feb 2 -330.723341 15154.90 -215.176757 Mar 2 -650.359571 15056.64 -483.279230 Apr 2 -824.444562 14932.75 117.693448 May 2 -1125.362789 14808.86 372.499363 Jun 2 -674.813278 14661.71 291.102737 Jul 2 1478.402950 14514.56 149.039395 Aug 2 2001.988842 14321.97 185.038430 Sep 2 669.074849 14129.39 881.537350 Oct 2 -6.045515 13879.86 212.186862 Nov 2 -587.165691 13630.33 85.836187 Dec 2 78.201435 13352.27 -344.470690 Jan 3 -28.753646 13074.21 50.544641 Feb 3 -330.723341 12800.79 -190.067768 Mar 3 -650.359571 12527.37 -343.013643 Apr 3 -824.444562 12282.74 -323.295412 May 3 -1125.362789 12038.11 -9.743944 Jun 3 -674.813278 11845.02 -244.209676 Jul 3 1478.402950 11651.94 89.657876 Aug 3 2001.988842 11503.43 75.577102 Sep 3 669.074849 11354.93 -236.003787 Oct 3 -6.045515 11239.33 -145.284440 Nov 3 -587.165691 11123.73 -102.565280 Dec 3 78.201435 11028.44 -45.642973 Jan 4 -28.753646 10933.15 -76.398459 Feb 4 -330.723341 10859.40 -258.679800 Mar 4 -650.359571 10785.65 224.705393 Apr 4 -824.444562 10746.65 -23.204632 May 4 -1125.362789 10707.64 -187.281421 Jun 4 -674.813278 10720.42 -101.604527 Jul 4 1478.402950 10733.19 -94.594349 Aug 4 2001.988842 10812.53 -340.521371 Sep 4 669.074849 10891.87 -454.948507 Oct 4 -6.045515 11026.96 -377.918737 Nov 4 -587.165691 11162.05 -347.889154 Dec 4 78.201435 11335.77 -140.969472 Jan 5 -28.753646 11509.48 35.272417 Feb 5 -330.723341 11695.09 218.634737 Mar 5 -650.359571 11880.70 374.663589 Apr 5 -824.444562 12064.77 173.677857 May 5 -1125.362789 12248.84 57.525361 Jun 5 -674.813278 12416.43 258.385465 Jul 5 1478.402950 12584.02 -55.421147 Aug 5 2001.988842 12712.16 -132.144066 Sep 5 669.074849 12840.29 -258.367100 Oct 5 -6.045515 12924.11 -112.060035 Nov 5 -587.165691 13007.92 224.246844 Dec 5 78.201435 13055.73 735.065687 Jan 6 -28.753646 13103.55 267.206736 Feb 6 -330.723341 13109.28 300.448209 Mar 6 -650.359571 13115.00 48.356215 Apr 6 -824.444562 13048.64 106.807419 May 6 -1125.362789 12982.27 25.091859 Jun 6 -674.813278 12911.14 151.677972 Jul 6 1478.402950 12840.00 75.597368 Aug 6 2001.988842 12763.54 -130.529550 Sep 6 669.074849 12687.08 -138.156582 Oct 6 -6.045515 12606.15 -46.100126 Nov 6 -587.165691 12525.21 92.956144 Dec 6 78.201435 12441.97 -91.171683 > m$win s t l 721 19 13 > m$deg s t l 0 1 1 > m$jump s t l 73 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/rcomp/tmp/1ziba1322504351.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/www/rcomp/tmp/2k5g01322504351.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/www/rcomp/tmp/3utrj1322504351.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/www/rcomp/tmp/4ecoz1322504351.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/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,'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/www/rcomp/tmp/5yin21322504351.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/www/rcomp/tmp/63g0k1322504351.tab") > > try(system("convert tmp/1ziba1322504351.ps tmp/1ziba1322504351.png",intern=TRUE)) character(0) > try(system("convert tmp/2k5g01322504351.ps tmp/2k5g01322504351.png",intern=TRUE)) character(0) > try(system("convert tmp/3utrj1322504351.ps tmp/3utrj1322504351.png",intern=TRUE)) character(0) > try(system("convert tmp/4ecoz1322504351.ps tmp/4ecoz1322504351.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.804 0.304 2.093