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(111.5,108.1,124.5,106.3,111.1,121.3,116.5,117.4,123.6,98.4,107.2,118.9,111.9,115.2,124.4,104.6,117,126.2,117.5,122.2,124.1,105.8,107.5,125.6,112.1,120.1,130.6,109.8,122.1,129.5,132.1,133.3,128.4,114.7,114.1,136.9,123.4,134,137,127.8,140.1,140.4,157.8,151.8,141.1,138.8,141.1,139.5,150.7,144.4,146,143.6,143.1,156.4,164.8,145.1,153.4,133.2,131.4,145.9) > 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 -3.5853481 113.2365 1.8488651 Feb 1 -1.7302535 113.3084 -3.4781816 Mar 1 5.8248342 113.3804 5.2947784 Apr 1 -8.6652581 113.4961 1.4691168 May 1 -0.8153412 113.6119 -1.6965540 Jun 1 6.8971848 113.7586 0.6442253 Jul 1 9.5097146 113.9053 -6.9149992 Aug 1 5.3583665 114.0421 -2.0004785 Sep 1 5.1470072 114.1789 4.2740534 Oct 1 -11.2504274 114.4027 -4.7523052 Nov 1 -9.6278691 114.6265 2.2013432 Dec 1 2.9373888 114.9460 1.0166523 Jan 2 -3.5853481 115.2654 0.2199562 Feb 2 -1.7302535 115.5181 1.4121850 Mar 2 5.8248342 115.7707 2.8044206 Apr 2 -8.6652581 115.9774 -2.7121537 May 2 -0.8153412 116.1841 1.6312629 Jun 2 6.8971848 116.4368 2.8660571 Jul 2 9.5097146 116.6894 -8.6991526 Aug 2 5.3583665 117.0459 -0.2043016 Sep 2 5.1470072 117.4024 1.5505606 Oct 2 -11.2504274 117.9033 -0.8528914 Nov 2 -9.6278691 118.4042 -1.2763363 Dec 2 2.9373888 119.0542 3.6083771 Jan 3 -3.5853481 119.7043 -4.0189147 Feb 3 -1.7302535 120.4286 1.4016550 Mar 3 5.8248342 121.1529 3.6222314 Apr 3 -8.6652581 121.8253 -3.3600573 May 3 -0.8153412 122.4977 0.4176448 Jun 3 6.8971848 123.2805 -0.6776907 Jul 3 9.5097146 124.0633 -1.4730299 Aug 3 5.3583665 125.0223 2.9193450 Sep 3 5.1470072 125.9813 -2.7282689 Oct 3 -11.2504274 127.1601 -1.2097013 Nov 3 -9.6278691 128.3390 -4.6111267 Dec 3 2.9373888 129.7914 4.1711887 Jan 4 -3.5853481 131.2438 -4.2585011 Feb 4 -1.7302535 132.8566 2.8737017 Mar 4 5.8248342 134.4693 -3.2940888 Apr 4 -8.6652581 136.1345 0.3307245 May 4 -0.8153412 137.7998 3.1155286 Jun 4 6.8971848 139.2896 -5.7867538 Jul 4 9.5097146 140.7793 7.5109600 Aug 4 5.3583665 141.9669 4.4747744 Sep 4 5.1470072 143.1544 -7.2013999 Oct 4 -11.2504274 144.0204 6.0300216 Nov 4 -9.6278691 144.8864 5.8414501 Dec 4 2.9373888 145.5094 -8.9467475 Jan 5 -3.5853481 146.1323 8.1530495 Feb 5 -1.7302535 146.4347 -0.3044885 Mar 5 5.8248342 146.7372 -6.5620197 Apr 5 -8.6652581 146.5286 5.7366835 May 5 -0.8153412 146.3200 -2.4046224 Jun 5 6.8971848 146.0682 3.4345988 Jul 5 9.5097146 145.8165 9.4738162 Aug 5 5.3583665 145.5530 -5.8113302 Sep 5 5.1470072 145.2895 2.9635346 Oct 5 -11.2504274 144.9798 -0.5293725 Nov 5 -9.6278691 144.6701 -3.6422725 Dec 5 2.9373888 144.3144 -1.3517886 > 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/1hvun1259929892.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/24z111259929892.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/3p1sb1259929892.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/4vs611259929892.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/5p4at1259929892.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/6rq3r1259929892.tab") > system("convert tmp/1hvun1259929892.ps tmp/1hvun1259929892.png") > system("convert tmp/24z111259929892.ps tmp/24z111259929892.png") > system("convert tmp/3p1sb1259929892.ps tmp/3p1sb1259929892.png") > system("convert tmp/4vs611259929892.ps tmp/4vs611259929892.png") > > > proc.time() user system elapsed 0.956 0.612 2.212