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(8,8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,8) > 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.009275983 7.944682 0.046041797 Feb 1 -0.040243253 7.893960 0.246283717 Mar 1 -0.229762214 7.843237 0.086525362 Apr 1 -0.327955572 7.798295 0.029660500 May 1 -0.106149113 7.753353 -0.047204179 Jun 1 0.230889002 7.713562 -0.144450534 Jul 1 0.347927142 7.673770 -0.221696916 Aug 1 0.270021690 7.636910 -0.106931885 Sep 1 0.132116513 7.600051 -0.232167129 Oct 1 -0.085656567 7.593380 -0.007723544 Nov 1 -0.283429660 7.586710 -0.203279946 Dec 1 0.082966215 7.620652 -0.203618623 Jan 2 0.009275983 7.654595 -0.163871192 Feb 2 -0.040243253 7.698893 -0.058650002 Mar 2 -0.229762214 7.743191 0.186570913 Apr 2 -0.327955572 7.774765 0.253190791 May 2 -0.106149113 7.806338 0.199810851 Jun 2 0.230889002 7.783507 0.085604302 Jul 2 0.347927142 7.760675 0.091397727 Aug 2 0.270021690 7.687516 0.242462364 Sep 2 0.132116513 7.614357 0.453526726 Oct 2 -0.085656567 7.529604 0.456053013 Nov 2 -0.283429660 7.444850 0.138579313 Dec 2 0.082966215 7.356796 -0.539762479 Jan 3 0.009275983 7.268742 -0.678018163 Feb 3 -0.040243253 7.176442 -0.436198571 Mar 3 -0.229762214 7.084141 0.045620746 Apr 3 -0.327955572 7.015431 0.312524967 May 3 -0.106149113 6.946720 0.259429370 Jun 3 0.230889002 6.911684 0.057427313 Jul 3 0.347927142 6.876648 -0.124574771 Aug 3 0.270021690 6.839203 -0.209224606 Sep 3 0.132116513 6.801758 0.066125285 Oct 3 -0.085656567 6.752593 0.133063913 Nov 3 -0.283429660 6.703427 -0.019997446 Dec 3 0.082966215 6.663493 -0.046459505 Jan 4 0.009275983 6.623559 -0.032835457 Feb 4 -0.040243253 6.578149 -0.137905512 Mar 4 -0.229762214 6.532738 -0.002975841 Apr 4 -0.327955572 6.486905 0.041050310 May 4 -0.106149113 6.441072 0.165076643 Jun 4 0.230889002 6.439714 0.129396987 Jul 4 0.347927142 6.438356 0.013717305 Aug 4 0.270021690 6.458252 -0.328274049 Sep 4 0.132116513 6.478149 -0.510265677 Oct 4 -0.085656567 6.484885 -0.599228929 Nov 4 -0.283429660 6.491622 -0.108192168 Dec 4 0.082966215 6.525720 0.591313408 Jan 5 0.009275983 6.559819 0.730905091 Feb 5 -0.040243253 6.650792 0.289450822 Mar 5 -0.229762214 6.741766 -0.412003721 Apr 5 -0.327955572 6.858795 -0.730839544 May 5 -0.106149113 6.975824 -0.669675184 Jun 5 0.230889002 7.087998 -0.218887222 Jul 5 0.347927142 7.200172 0.151900713 Aug 5 0.270021690 7.316746 0.313231937 Sep 5 0.132116513 7.433321 0.134562886 Oct 5 -0.085656567 7.556632 -0.070975670 Nov 5 -0.283429660 7.679944 0.103485786 Dec 5 0.082966215 7.807799 0.109234948 > 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/www/html/rcomp/tmp/1sj3p1260545414.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/2njqq1260545414.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/37dzo1260545414.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/4t8mz1260545414.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/52bff1260545414.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/6kqnl1260545414.tab") > system("convert tmp/1sj3p1260545414.ps tmp/1sj3p1260545414.png") > system("convert tmp/2njqq1260545414.ps tmp/2njqq1260545414.png") > system("convert tmp/37dzo1260545414.ps tmp/37dzo1260545414.png") > system("convert tmp/4t8mz1260545414.ps tmp/4t8mz1260545414.png") > > > proc.time() user system elapsed 0.976 0.628 1.831