R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing 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(6.02,5.62,4.87,4.24,4.02,3.74,3.45,3.34,3.21,3.12,3.04,2.97,2.93,2.95,2.92,2.9,2.95,2.91,2.89,2.84,2.82,2.78,2.86,2.87,2.94,3.04,3.12,3.19,3.27,3.34,3.4,3.55,3.64,3.76,3.78,3.77,3.81,3.81,3.82,3.96,3.86,3.84,3.68,3.56,3.48,3.4,3.42,3.2,3.11,3.1,2.99,3.1,3,3.05,3.1,3.2,3.1,3.3,3.13,3.14) > par8 = 'FALSE' > par7 = '1' > par6 = '' > par5 = '1' > par4 = '' > par3 = '0' > par2 = 'periodic' > par1 = '12' > main = 'Seasonal Decomposition by Loess' > par8 <- 'FALSE' > par7 <- '1' > par6 <- '' > par5 <- '1' > par4 <- '' > par3 <- '0' > par2 <- 'periodic' > par1 <- '12' > #'GNU S' R Code compiled by R2WASP v. 1.2.327 () > #Author: root > #To cite this work: Wessa P., (2013), Decomposition by Loess (v1.0.2) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_decomposeloess.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > 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.158600416 5.270678 0.590721633 Feb 1 0.150240714 5.031249 0.438510253 Mar 1 0.039881120 4.791820 0.038298766 Apr 1 0.005569801 4.563355 -0.328925075 May 1 -0.020741590 4.334890 -0.294148844 Jun 1 -0.035815196 4.113623 -0.337807452 Jul 1 -0.078888818 3.892355 -0.363466045 Aug 1 -0.052132596 3.677031 -0.284898765 Sep 1 -0.067376323 3.461708 -0.184331536 Oct 1 -0.018538615 3.313139 -0.174600730 Nov 1 -0.017700810 3.164571 -0.106870021 Dec 1 -0.063097767 3.094378 -0.061279831 Jan 2 0.158600416 3.024184 -0.252784782 Feb 2 0.150240714 2.985272 -0.185512547 Mar 2 0.039881120 2.946359 -0.066240419 Apr 2 0.005569801 2.926388 -0.031957665 May 2 -0.020741590 2.906416 0.064325161 Jun 2 -0.035815196 2.900238 0.045577176 Jul 2 -0.078888818 2.894060 0.074829207 Aug 2 -0.052132596 2.898893 -0.006760441 Sep 2 -0.067376323 2.903726 -0.016350139 Oct 2 -0.018538615 2.920525 -0.121985936 Nov 2 -0.017700810 2.937323 -0.059621829 Dec 2 -0.063097767 2.973070 -0.039972587 Jan 3 0.158600416 3.008818 -0.227418487 Feb 3 0.150240714 3.068032 -0.178272457 Mar 3 0.039881120 3.127245 -0.047126534 Apr 3 0.005569801 3.205144 -0.020713325 May 3 -0.020741590 3.283042 0.007699955 Jun 3 -0.035815196 3.362934 0.012881106 Jul 3 -0.078888818 3.442827 0.036062273 Aug 3 -0.052132596 3.511132 0.091000234 Sep 3 -0.067376323 3.579438 0.127938144 Oct 3 -0.018538615 3.632695 0.145843140 Nov 3 -0.017700810 3.685953 0.111748040 Dec 3 -0.063097767 3.720238 0.112860230 Jan 4 0.158600416 3.754522 -0.103122721 Feb 4 0.150240714 3.760435 -0.100675379 Mar 4 0.039881120 3.766347 0.013771857 Apr 4 0.005569801 3.745755 0.208674997 May 4 -0.020741590 3.725163 0.155578209 Jun 4 -0.035815196 3.681532 0.194282840 Jul 4 -0.078888818 3.637901 0.120987486 Aug 4 -0.052132596 3.572364 0.039768512 Sep 4 -0.067376323 3.506827 0.040549488 Oct 4 -0.018538615 3.430310 -0.011771689 Nov 4 -0.017700810 3.353794 0.083907038 Dec 4 -0.063097767 3.289559 -0.026461429 Jan 5 0.158600416 3.225325 -0.273925036 Feb 5 0.150240714 3.186565 -0.236805666 Mar 5 0.039881120 3.147805 -0.197686403 Apr 5 0.005569801 3.148071 -0.053640647 May 5 -0.020741590 3.148336 -0.127594820 Jun 5 -0.035815196 3.150251 -0.064436108 Jul 5 -0.078888818 3.152166 0.026722619 Aug 5 -0.052132596 3.158076 0.094056562 Sep 5 -0.067376323 3.163986 0.003390455 Oct 5 -0.018538615 3.173584 0.144954843 Nov 5 -0.017700810 3.183182 -0.035480865 Dec 5 -0.063097767 3.194765 0.008332397 > m$win s t l 601 19 13 > m$deg s t l 0 1 1 > m$jump s t l 61 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/wessaorg/rcomp/tmp/1rws61384347123.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/2epfw1384347123.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/3fw8f1384347123.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/4k33s1384347123.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/532sq1384347123.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/60hip1384347123.tab") > > try(system("convert tmp/1rws61384347123.ps tmp/1rws61384347123.png",intern=TRUE)) character(0) > try(system("convert tmp/2epfw1384347123.ps tmp/2epfw1384347123.png",intern=TRUE)) character(0) > try(system("convert tmp/3fw8f1384347123.ps tmp/3fw8f1384347123.png",intern=TRUE)) character(0) > try(system("convert tmp/4k33s1384347123.ps tmp/4k33s1384347123.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.391 0.454 2.825