R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(22,22,20,21,20,21,21,21,19,21,21,22,19,24,22,22,22,24,22,23,24,21,20,22,23,23,22,20,21,21,20,20,17,18,19,19,20,21,20,21,19,22,20,18,16,17,18,19,18,20,21,18,19,19,19,21,19,19,17,16,16,17,16,15,16,16,16,18,19,16,16,16) > par8 = 'FALSE' > par7 = '1' > par6 = '' > par5 = '1' > par4 = '' > par3 = '0' > par2 = 'periodic' > par1 = '12' > main = 'Seasonal Decomposition by Loess' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > 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.17995847 20.63534 1.544621579 Feb 1 1.36098354 20.66085 -0.021833145 Mar 1 0.40192556 20.68636 -1.088287868 Apr 1 -0.24744238 20.72221 0.525231570 May 1 -0.23014343 20.75806 -0.527915870 Jun 1 0.81840273 20.80003 -0.618428003 Jul 1 0.03361434 20.84199 0.124394410 Aug 1 0.59339709 20.89278 -0.486180014 Sep 1 -0.51348688 20.94357 -1.430087717 Oct 1 -0.78848675 21.06518 0.723309252 Nov 1 -0.89682021 21.18678 0.710039817 Dec 1 -0.35198467 21.36302 0.988964068 Jan 2 -0.17995847 21.53926 -2.359302334 Feb 2 1.36098354 21.72340 0.915619886 Mar 2 0.40192556 21.90753 -0.309457894 Apr 2 -0.24744238 22.02956 0.217878105 May 2 -0.23014343 22.15160 0.078547227 Jun 2 0.81840273 22.22316 0.958441318 Jul 2 0.03361434 22.29472 -0.328330047 Aug 2 0.59339709 22.31266 0.093947209 Sep 2 -0.51348688 22.33060 2.182891184 Oct 2 -0.78848675 22.23778 -0.449292649 Nov 2 -0.89682021 22.14496 -1.248142885 Dec 2 -0.35198467 21.94955 0.402432538 Jan 3 -0.17995847 21.75414 1.425817307 Feb 3 1.36098354 21.46630 0.172713237 Mar 3 0.40192556 21.17847 0.419609166 Apr 3 -0.24744238 20.87005 -0.622606964 May 3 -0.23014343 20.56163 0.668510028 Jun 3 0.81840273 20.31240 -0.130798366 Jul 3 0.03361434 20.06316 -0.096772214 Aug 3 0.59339709 19.89148 -0.484879604 Sep 3 -0.51348688 19.71981 -2.206320274 Oct 3 -0.78848675 19.66102 -0.872529219 Nov 3 -0.89682021 19.60222 0.294595433 Dec 3 -0.35198467 19.61581 -0.263828781 Jan 4 -0.17995847 19.62940 0.550556351 Feb 4 1.36098354 19.60303 0.035987815 Mar 4 0.40192556 19.57666 0.021419280 Apr 4 -0.24744238 19.48316 1.764285227 May 4 -0.23014343 19.38966 -0.159515703 Jun 4 0.81840273 19.26317 1.918427746 Jul 4 0.03361434 19.13668 0.829705741 Aug 4 0.59339709 19.03130 -1.624692448 Sep 4 -0.51348688 18.92591 -2.412423918 Oct 4 -0.78848675 18.83062 -1.042136984 Nov 4 -0.89682021 18.73534 0.161483546 Dec 4 -0.35198467 18.70714 0.644845201 Jan 5 -0.17995847 18.67894 -0.498983798 Feb 5 1.36098354 18.77698 -0.137967261 Mar 5 0.40192556 18.87503 1.723049277 Apr 5 -0.24744238 18.95650 -0.709058127 May 5 -0.23014343 19.03798 0.192167592 Jun 5 0.81840273 18.93067 -0.749070734 Jul 5 0.03361434 18.82336 0.143025485 Aug 5 0.59339709 18.56914 1.837465172 Sep 5 -0.51348688 18.31492 1.198571579 Oct 5 -0.78848675 17.99779 1.790700658 Nov 5 -0.89682021 17.68066 0.216163334 Dec 5 -0.35198467 17.36569 -1.013709815 Jan 6 -0.17995847 17.05073 -0.870773617 Feb 6 1.36098354 16.82111 -1.182093708 Mar 6 0.40192556 16.59149 -0.993413799 Apr 6 -0.24744238 16.61098 -1.363535537 May 6 -0.23014343 16.63047 -0.400324153 Jun 6 0.81840273 16.63803 -1.456427794 Jul 6 0.03361434 16.64558 -0.679196890 Aug 6 0.59339709 16.68182 0.724783807 Sep 6 -0.51348688 16.71806 2.795431223 Oct 6 -0.78848675 16.78659 0.001901372 Nov 6 -0.89682021 16.85512 0.041705118 Dec 6 -0.35198467 16.93909 -0.587100512 > 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/html/rcomp/tmp/1epnd1259858408.ps",horizontal=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/html/rcomp/tmp/26mrq1259858408.ps",horizontal=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/html/rcomp/tmp/3pncx1259858408.ps",horizontal=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/html/rcomp/tmp/4b5751259858408.ps",horizontal=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/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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/html/rcomp/tmp/5bur11259858408.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/html/rcomp/tmp/6uv821259858408.tab") > > system("convert tmp/1epnd1259858408.ps tmp/1epnd1259858408.png") > system("convert tmp/26mrq1259858408.ps tmp/26mrq1259858408.png") > system("convert tmp/3pncx1259858408.ps tmp/3pncx1259858408.png") > system("convert tmp/4b5751259858408.ps tmp/4b5751259858408.png") > > > proc.time() user system elapsed 1.000 0.617 1.208