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(149,139,135,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) > 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 10.4079880 134.9250 3.6669839 Feb 1 1.8736978 134.6702 2.4560562 Mar 1 -0.8605927 134.4155 1.4451289 Apr 1 -2.3989981 134.2262 -1.8271524 May 1 -5.1374052 134.0368 -1.8994319 Jun 1 -9.6655992 133.8684 -2.2028453 Jul 1 -12.1937915 133.7001 -4.5062603 Aug 1 -18.3969437 133.5070 -3.1100641 Sep 1 -16.8000971 133.3140 -3.5138665 Oct 1 14.4758323 133.1898 1.3343828 Nov 1 20.5517616 133.0656 3.3826323 Dec 1 18.1441468 132.8088 6.0470519 Jan 2 10.4079880 132.5520 4.0400155 Feb 2 1.8736978 132.1681 2.9582262 Mar 2 -0.8605927 131.7842 1.0764372 Apr 2 -2.3989981 131.2228 -3.8238085 May 2 -5.1374052 130.6615 -2.5240526 Jun 2 -9.6655992 129.9276 -3.2619658 Jul 2 -12.1937915 129.1937 -2.9998808 Aug 2 -18.3969437 128.3441 1.0528568 Sep 2 -16.8000971 127.4945 1.3055957 Oct 2 14.4758323 126.5740 2.9501822 Nov 2 20.5517616 125.6535 3.7947688 Dec 2 18.1441468 124.5428 6.3130654 Jan 3 10.4079880 123.4321 0.1599061 Feb 3 1.8736978 121.9904 -0.8641398 Mar 3 -0.8605927 120.5488 -3.6881853 Apr 3 -2.3989981 118.8647 0.5342739 May 3 -5.1374052 117.1807 -1.0432652 Jun 3 -9.6655992 115.5191 -0.8534845 Jul 3 -12.1937915 113.8575 0.3362946 Aug 3 -18.3969437 112.4918 0.9051773 Sep 3 -16.8000971 111.1260 -1.3259387 Oct 3 14.4758323 110.0770 -0.5528197 Nov 3 20.5517616 109.0279 0.4202994 Dec 3 18.1441468 108.1934 -2.3375297 Jan 4 10.4079880 107.3588 -2.7668148 Feb 4 1.8736978 106.6714 -2.5451200 Mar 4 -0.8605927 105.9840 -0.1234248 Apr 4 -2.3989981 105.3831 2.0159254 May 4 -5.1374052 104.7821 1.3552773 Jun 4 -9.6655992 104.2363 0.4293486 Jul 4 -12.1937915 103.6904 1.5034182 Aug 4 -18.3969437 103.4053 -1.0083744 Sep 4 -16.8000971 103.1203 0.6798343 Oct 4 14.4758323 103.3636 -1.8394460 Nov 4 20.5517616 103.6070 -4.1587262 Dec 4 18.1441468 104.5237 -5.6678367 Jan 5 10.4079880 105.4404 -6.8484031 Feb 5 1.8736978 106.8446 -3.7183100 Mar 5 -0.8605927 108.2488 -0.3882165 Apr 5 -2.3989981 109.7414 1.6576189 May 5 -5.1374052 111.2339 2.9034559 Jun 5 -9.6655992 112.6804 4.9852017 Jul 5 -12.1937915 114.1268 5.0669457 Aug 5 -18.3969437 115.5878 1.8091627 Sep 5 -16.8000971 117.0487 2.7513809 Oct 5 14.4758323 118.4597 -1.9355742 Nov 5 20.5517616 119.8708 -3.4225291 Dec 5 18.1441468 121.2139 -4.3580547 > 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/1u7nj1259672093.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/2fb2f1259672093.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/35qnk1259672093.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/4p9wu1259672093.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/5jxol1259672093.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/65r1i1259672093.tab") > system("convert tmp/1u7nj1259672093.ps tmp/1u7nj1259672093.png") > system("convert tmp/2fb2f1259672093.ps tmp/2fb2f1259672093.png") > system("convert tmp/35qnk1259672093.ps tmp/35qnk1259672093.png") > system("convert tmp/4p9wu1259672093.ps tmp/4p9wu1259672093.png") > > > proc.time() user system elapsed 0.943 0.593 1.175