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(102.80,118.72,119.01,118.61,120.43,111.83,116.79,131.71,120.57,117.83,130.80,107.46,112.09,129.47,119.72,134.81,135.80,129.27,126.94,153.45,121.86,133.47,135.34,117.10,120.65,132.49,137.60,138.69,125.53,133.09,129.08,145.94,129.07,139.69,142.09,137.29,127.03,137.25,156.87,150.89,139.14,158.30,149.00,158.36,168.06,153.38,173.86,162.47,145.17,168.89,166.64,140.07,128.84,123.40,120.30,129.66,118.12,113.91,131.09,119.14,115.33) > 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 -9.529247 114.3988 -2.0695627 Feb 1 4.000999 115.1439 -0.4248747 Mar 1 6.466243 115.8889 -3.3451844 Apr 1 2.988164 116.5818 -0.9599538 May 1 -3.801925 117.2746 6.9572873 Jun 1 -2.789686 117.9473 -3.3276522 Jul 1 -5.763457 118.6200 3.9334181 Aug 1 9.575738 119.3152 2.8190475 Sep 1 -2.775071 120.0104 3.3346808 Oct 1 -2.428289 120.7805 -0.5222479 Nov 1 8.778486 121.5507 0.4708316 Dec 1 -4.721954 122.6613 -10.4793158 Jan 2 -9.529247 123.7719 -2.1526107 Feb 2 4.000999 125.0253 0.4436798 Mar 2 6.466243 126.2788 -13.0250275 Apr 2 2.988164 127.3810 4.4408740 May 2 -3.801925 128.4831 11.1187858 Jun 2 -2.789686 129.2947 2.7649852 Jul 2 -5.763457 130.1063 2.5971944 Aug 2 9.575738 130.5451 13.3291466 Sep 2 -2.775071 130.9840 -6.3488973 Oct 2 -2.428289 131.0481 4.8501823 Nov 2 8.778486 131.1122 -4.5507300 Dec 2 -4.721954 131.0121 -9.1900957 Jan 3 -9.529247 130.9119 -0.7326089 Feb 3 4.000999 131.1095 -2.6205008 Mar 3 6.466243 131.3071 -0.1733905 Apr 3 2.988164 131.9693 3.7325476 May 3 -3.801925 132.6314 -3.2995039 Jun 3 -2.789686 133.5001 2.3796315 Jul 3 -5.763457 134.3687 0.4747768 Aug 3 9.575738 135.2552 1.1090715 Sep 3 -2.775071 136.1417 -4.2966300 Oct 3 -2.428289 137.2557 4.8625524 Nov 3 8.778486 138.3698 -5.0582572 Dec 3 -4.721954 139.9013 2.1106114 Jan 4 -9.529247 141.4329 -4.8736676 Feb 4 4.000999 143.3215 -10.0725102 Mar 4 6.466243 145.2101 5.1936495 Apr 4 2.988164 147.3982 0.5035890 May 4 -3.801925 149.5864 -6.6444611 Jun 4 -2.789686 151.7639 9.3257512 Jul 4 -5.763457 153.9415 0.8219733 Aug 4 9.575738 155.5145 -6.7302458 Sep 4 -2.775071 157.0875 13.7475391 Oct 4 -2.428289 157.0111 -1.2027943 Nov 4 8.778486 156.9346 8.1468805 Dec 4 -4.721954 155.0376 12.1543685 Jan 5 -9.529247 153.1405 1.5587090 Feb 5 4.000999 149.8844 15.0046453 Mar 5 6.466243 146.6282 13.5455837 Apr 5 2.988164 142.8847 -5.8028359 May 5 -3.801925 139.1412 -6.4992451 Jun 5 -2.789686 135.8390 -9.6493053 Jul 5 -5.763457 132.5368 -6.4733557 Aug 5 9.575738 129.2262 -9.1419134 Sep 5 -2.775071 125.9155 -5.0204673 Oct 5 -2.428289 122.6862 -6.3479230 Nov 5 8.778486 119.4569 2.8546294 Dec 5 -4.721954 116.4221 7.4399007 Jan 6 -9.529247 113.3872 11.4720244 > 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/html/rcomp/tmp/1ijvl1259966524.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/2a7ed1259966524.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/3ncle1259966524.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/4b2de1259966524.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/5ywx01259966524.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/6u6ln1259966524.tab") > system("convert tmp/1ijvl1259966524.ps tmp/1ijvl1259966524.png") > system("convert tmp/2a7ed1259966524.ps tmp/2a7ed1259966524.png") > system("convert tmp/3ncle1259966524.ps tmp/3ncle1259966524.png") > system("convert tmp/4b2de1259966524.ps tmp/4b2de1259966524.png") > > > proc.time() user system elapsed 0.963 0.614 1.138