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(19,18,19,19,22,23,20,14,14,14,15,11,17,16,20,24,23,20,21,19,23,23,23,23,27,26,17,24,26,24,27,27,26,24,23,23,24,17,21,19,22,22,18,16,14,12,14,16,8,3,0,5,1,1,3,6,7,8,14,14,13) > 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.0323505 20.388177 -2.42052740 Feb 1 -1.9169315 19.928233 -0.01130145 Mar 1 -2.2307931 19.468289 1.76250416 Apr 1 0.6607241 19.033869 -0.69459328 May 1 1.3522417 18.599449 2.04830902 Jun 1 0.5737907 18.226725 4.19948387 Jul 1 0.3953414 17.854002 1.75065698 Aug 1 -0.8573198 17.540903 -2.68358288 Sep 1 -0.3099816 17.227804 -2.91782225 Oct 1 -0.6944070 17.082084 -2.38767740 Nov 1 1.1211668 16.936365 -3.05753180 Dec 1 0.8738235 17.159328 -7.03315192 Jan 2 1.0323505 17.382292 -1.41464240 Feb 2 -1.9169315 17.901610 0.01532174 Mar 2 -2.2307931 18.420928 3.80986556 Apr 2 0.6607241 19.169733 4.16954315 May 2 1.3522417 19.918538 1.72922049 Jun 2 0.5737907 20.646481 -1.22027117 Jul 2 0.3953414 21.374423 -0.76976457 Aug 2 -0.8573198 21.816885 -1.95956513 Sep 2 -0.3099816 22.259347 1.05063480 Oct 2 -0.6944070 22.496584 1.19782267 Nov 2 1.1211668 22.733822 -0.85498871 Dec 2 0.8738235 23.048896 -0.92271954 Jan 3 1.0323505 23.363970 2.60367928 Feb 3 -1.9169315 23.735393 4.18153847 Mar 3 -2.2307931 24.106816 -4.87602267 Apr 3 0.6607241 24.293221 -0.95394503 May 3 1.3522417 24.479626 0.16813236 Jun 3 0.5737907 24.427762 -1.00155219 Jul 3 0.3953414 24.375897 2.22876151 Aug 3 -0.8573198 24.156311 3.70100854 Sep 3 -0.3099816 23.936726 2.37325606 Oct 3 -0.6944070 23.631151 1.06325641 Nov 3 1.1211668 23.325576 -1.44674249 Dec 3 0.8738235 22.800667 -0.67449014 Jan 4 1.0323505 22.275758 0.69189186 Feb 4 -1.9169315 21.519205 -2.60227400 Mar 4 -2.2307931 20.762653 2.46813982 Apr 4 0.6607241 19.920733 -1.58145732 May 4 1.3522417 19.078813 1.56894530 Jun 4 0.5737907 18.138505 3.28770446 Jul 4 0.3953414 17.198197 0.40646188 Aug 4 -0.8573198 15.943513 0.91380715 Sep 4 -0.3099816 14.688829 -0.37884709 Oct 4 -0.6944070 13.146902 -0.45249489 Nov 4 1.1211668 11.604975 1.27385805 Dec 4 0.8738235 10.082920 5.04325659 Jan 5 1.0323505 8.560865 -1.59321523 Feb 5 -1.9169315 7.484566 -2.56763437 Mar 5 -2.2307931 6.408267 -4.17747384 Apr 5 0.6607241 6.265628 -1.92635208 May 5 1.3522417 6.122989 -6.47523057 Jun 5 0.5737907 6.527825 -6.10161586 Jul 5 0.3953414 6.932661 -4.32800290 Aug 5 -0.8573198 7.400027 -0.54270740 Sep 5 -0.3099816 7.867393 -0.55741141 Oct 5 -0.6944070 8.463603 0.23080360 Nov 5 1.1211668 9.059814 3.81901935 Dec 5 0.8738235 9.793398 3.33277826 Jan 6 1.0323505 10.526983 1.44066682 > 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/1js5m1259929271.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/2pho11259929271.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/3cl7d1259929271.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/4rrqx1259929271.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/5ekfg1259929271.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/644ch1259929271.tab") > system("convert tmp/1js5m1259929271.ps tmp/1js5m1259929271.png") > system("convert tmp/2pho11259929271.ps tmp/2pho11259929271.png") > system("convert tmp/3cl7d1259929271.ps tmp/3cl7d1259929271.png") > system("convert tmp/4rrqx1259929271.ps tmp/4rrqx1259929271.png") > > > proc.time() user system elapsed 0.974 0.635 1.173