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(126.51,131.02,136.51,138.04,132.92,129.61,122.96,124.04,121.29,124.56,118.53,113.14,114.15,122.17,129.23,131.19,129.12,128.28,126.83,138.13,140.52,146.83,135.14,131.84,125.7,128.98,133.25,136.76,133.24,128.54,121.08,120.23,119.08,125.75,126.89,126.6,121.89,123.44,126.46,129.49,127.78,125.29,119.02,119.96,122.86,131.89,132.73,135.01,136.71,142.73,144.43,144.93,138.75,130.22,122.19,128.4,140.43,153.5,149.33,142.97) > 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 -4.5918006 133.7729 -2.6711027 Feb 1 0.1384822 132.5928 -1.7113119 Mar 1 4.5007663 131.4128 0.5964776 Apr 1 6.4990034 130.2316 1.3094048 May 1 2.6712410 129.0504 1.1983316 Jun 1 -1.5250975 127.9187 3.2164067 Jul 1 -7.7194365 126.7870 3.8924824 Aug 1 -4.2097826 125.7347 2.5150445 Sep 1 -1.7521302 124.6825 -1.6403920 Oct 1 5.7270733 123.8565 -5.0235282 Nov 1 1.5542787 123.0304 -6.0546664 Dec 1 -1.2925984 123.0567 -8.6240716 Jan 2 -4.5918006 123.0830 -4.3411519 Feb 2 0.1384822 124.1742 -2.1427002 Mar 2 4.5007663 125.2655 -0.5362497 Apr 2 6.4990034 127.0444 -2.3534398 May 2 2.6712410 128.8234 -2.3746304 Jun 2 -1.5250975 130.3500 -0.5449018 Jul 2 -7.7194365 131.8766 2.6728274 Aug 2 -4.2097826 132.6791 9.6606557 Sep 2 -1.7521302 133.4816 8.7904854 Oct 2 5.7270733 133.6830 7.4199197 Nov 2 1.5542787 133.8844 -0.2986481 Dec 2 -1.2925984 133.4518 -0.3191607 Jan 3 -4.5918006 133.0191 -2.7273483 Feb 3 0.1384822 131.8906 -3.0490431 Mar 3 4.5007663 130.7620 -2.0127390 Apr 3 6.4990034 129.5688 0.6921933 May 3 2.6712410 128.3756 2.1931250 Jun 3 -1.5250975 127.6618 2.4033185 Jul 3 -7.7194365 126.9479 1.8515126 Aug 3 -4.2097826 126.4283 -1.9885029 Sep 3 -1.7521302 125.9086 -5.0765170 Oct 3 5.7270733 125.4127 -5.3897266 Nov 3 1.5542787 124.9167 0.4190616 Dec 3 -1.2925984 124.6772 3.2154143 Jan 4 -4.5918006 124.4377 2.0440919 Feb 4 0.1384822 124.5291 -1.2275478 Mar 4 4.5007663 124.6204 -2.6611887 Apr 4 6.4990034 124.9573 -1.9663030 May 4 2.6712410 125.2942 -0.1854178 Jun 4 -1.5250975 126.0678 0.7473302 Jul 4 -7.7194365 126.8414 -0.1019214 Aug 4 -4.2097826 128.1699 -4.0000781 Sep 4 -1.7521302 129.4984 -4.8862334 Oct 4 5.7270733 130.8464 -4.6834261 Nov 4 1.5542787 132.1943 -1.0186208 Dec 4 -1.2925984 133.1185 3.1840814 Jan 5 -4.5918006 134.0427 7.2591086 Feb 5 0.1384822 134.8786 7.7129347 Mar 5 4.5007663 135.7145 4.2147595 Apr 5 6.4990034 136.6477 1.7833410 May 5 2.6712410 137.5808 -1.5020781 Jun 5 -1.5250975 138.4692 -6.7241248 Jul 5 -7.7194365 139.3576 -9.4481710 Aug 5 -4.2097826 140.1636 -7.5537905 Sep 5 -1.7521302 140.9695 1.2125915 Oct 5 5.7270733 141.8032 5.9697165 Nov 5 1.5542787 142.6369 5.1388394 Dec 5 -1.2925984 143.5332 0.7293723 > 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/16kgq1259956434.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/237dn1259956434.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/3t7z01259956434.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/4v3pw1259956434.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/5absv1259956434.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/62tjd1259956434.tab") > system("convert tmp/16kgq1259956434.ps tmp/16kgq1259956434.png") > system("convert tmp/237dn1259956434.ps tmp/237dn1259956434.png") > system("convert tmp/3t7z01259956434.ps tmp/3t7z01259956434.png") > system("convert tmp/4v3pw1259956434.ps tmp/4v3pw1259956434.png") > > > proc.time() user system elapsed 0.949 0.605 1.131