R version 2.12.0 (2010-10-15) 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(130,127,122,117,112,113,149,157,157,147,137,132,125,123,117,114,111,112,144,150,149,134,123,116,117,111,105,102,95,93,124,130,124,115,106,105,105,101,95,93,84,87,116,120,117,109,105,107,109,109,108,107,99,103,131,137,135,124,118,121,121) > 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 -1.7185958 131.2630 0.45558314 Feb 1 -4.7528213 131.5449 0.20793198 Mar 1 -9.3080748 131.8268 -0.51869125 Apr 1 -11.8255274 132.0342 -3.20864059 May 1 -17.9429802 132.2416 -2.29858981 Jun 1 -16.3666045 132.3443 -2.97766742 Jul 1 15.0097717 132.4470 1.54325435 Aug 1 21.0642683 132.4852 3.45055946 Sep 1 18.7187641 132.5234 5.75786532 Oct 1 8.1673414 132.3973 6.43538146 Nov 1 0.2159184 132.2712 4.51289785 Dec 1 -1.2614653 131.7886 1.47281799 Jan 2 -1.7185958 131.3061 -4.58751506 Feb 2 -4.7528213 130.6114 -2.85856892 Mar 2 -9.3080748 129.9167 -3.60859486 Apr 2 -11.8255274 129.0966 -3.27112218 May 2 -17.9429802 128.2766 0.66635062 Jun 2 -16.3666045 127.4273 0.93928102 Jul 2 15.0097717 126.5780 2.41221079 Aug 2 21.0642683 125.6203 3.31548160 Sep 2 18.7187641 124.6625 5.61875316 Oct 2 8.1673414 123.4032 2.42944323 Nov 2 0.2159184 122.1439 0.64013354 Dec 2 -1.2614653 120.5376 -3.27610125 Jan 3 -1.7185958 118.9312 -0.21258922 Feb 3 -4.7528213 117.1799 -1.42708844 Mar 3 -9.3080748 115.4286 -1.12055973 Apr 3 -11.8255274 113.8710 -0.04549738 May 3 -17.9429802 112.3134 0.62956510 Jun 3 -16.3666045 111.1526 -1.78598143 Jul 3 15.0097717 109.9918 -1.00152858 Aug 3 21.0642683 109.0949 -0.15911892 Sep 3 18.7187641 108.1979 -2.91670851 Oct 3 8.1673414 107.4528 -0.62013798 Nov 3 0.2159184 106.7076 -0.92356720 Dec 3 -1.2614653 106.0588 0.20262767 Jan 4 -1.7185958 105.4100 1.30856935 Feb 4 -4.7528213 104.7837 0.96914780 Mar 4 -9.3080748 104.1573 0.15075417 Apr 4 -11.8255274 103.6912 1.13429022 May 4 -17.9429802 103.2252 -1.28217361 Jun 4 -16.3666045 103.2008 0.16583751 Jul 4 15.0097717 103.1764 -2.18615200 Aug 4 21.0642683 103.7967 -4.86100375 Sep 4 18.7187641 104.4171 -6.13585476 Oct 4 8.1673414 105.6218 -4.78917267 Nov 4 0.2159184 106.8266 -2.04249033 Dec 4 -1.2614653 108.3485 -0.08701144 Jan 5 -1.7185958 109.8704 0.84821426 Feb 5 -4.7528213 111.3805 2.37236847 Mar 5 -9.3080748 112.8905 4.41755059 Apr 5 -11.8255274 113.9404 4.88512847 May 5 -17.9429802 114.9903 1.95270646 Jun 5 -16.3666045 115.8497 3.51694998 Jul 5 15.0097717 116.7090 -0.71880712 Aug 5 21.0642683 117.5154 -1.57970211 Sep 5 18.7187641 118.3218 -2.04059635 Oct 5 8.1673414 119.0506 -3.21789592 Nov 5 0.2159184 119.7793 -1.99519525 Dec 5 -1.2614653 120.4641 1.79740917 Jan 6 -1.7185958 121.1488 1.56976040 > m$win s t l 611 19 13 > m$deg s t l 0 1 1 > m$jump s t l 62 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/rcomp/tmp/1u1kf1292442612.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/2u1kf1292442612.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/3u1kf1292442612.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/44tk01292442612.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/5ikh91292442612.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/64lyf1292442612.tab") > try(system("convert tmp/1u1kf1292442612.ps tmp/1u1kf1292442612.png",intern=TRUE)) character(0) > try(system("convert tmp/2u1kf1292442612.ps tmp/2u1kf1292442612.png",intern=TRUE)) character(0) > try(system("convert tmp/3u1kf1292442612.ps tmp/3u1kf1292442612.png",intern=TRUE)) character(0) > try(system("convert tmp/44tk01292442612.ps tmp/44tk01292442612.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.160 0.690 1.844