R version 2.8.0 (2008-10-20) Copyright (C) 2008 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. Natural language support but running in an English locale 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(6.4,7.7,9.2,8.6,7.4,8.6,6.2,6,6.6,5.1,4.7,5,3.6,1.9,-0.1,-5.7,-5.6,-6.4,-7.7,-8,-11.9,-15.4,-15.5,-13.4,-10.9,-10.8,-7.3,-6.5,-5.1,-5.3,-6.8,-8.4,-8.4,-9.7,-8.8,-9.6,-11.5,-11,-14.9,-16.2,-14.4,-17.3,-15.7,-12.6,-9.4,-8.1,-5.4,-4.6,-4.9,-4,-3.1,-1.3,0,-0.4,3,0.4,1.2,0.6,-1.3,-3.2,-1.8,-3.6,-4.2,-6.9,-8,-7.5,-8.2,-7.6,-3.7,-1.7,-0.7,0.2,0.6,2.2,3.3,5.3,5.5,6.3,7.7,6.5,5.5,6.9,5.7,6.9,6.1,4.8,3.7,5.8,6.8,8.5,7.2,5,4.7,2.3,2.4,0.1,1.9,1.7,2,-1.9,0.5,-1.3,-3.3,-2.8,-8,-13.9,-21.9,-28.8,-27.6,-31.4,-31.8,-29.4,-27.6,-23.6,-22.8,-18.2,-17.8,-14.2,-8.8,-7.9,-7,-7,-3.6,-2.4,-4.9,-7.7,-6.5,-5.1,-3.4,-2.8,0.8) > 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 -0.21580196 9.07704890 -2.46124694 Feb 1 -0.47350335 8.65287316 -0.47936982 Mar 1 -0.08575142 8.22869742 1.05705400 Apr 1 -0.33531016 7.77981755 1.15549261 May 1 0.23331359 7.33093769 -0.16425128 Jun 1 0.21954602 6.85816596 1.52228802 Jul 1 0.19668827 6.38539423 -0.38208250 Aug 1 0.41625320 5.87067460 -0.28692780 Sep 1 0.46309233 5.35595497 0.78095270 Oct 1 -0.07051108 4.55103681 0.61947426 Nov 1 0.15952026 3.74611865 0.79436109 Dec 1 -0.50753511 2.57922019 2.92831492 Jan 2 -0.21580196 1.41232172 2.40348024 Feb 2 -0.47350335 0.02431152 2.34919183 Mar 2 -0.08575142 -1.36369868 1.34945010 Apr 2 -0.33531016 -2.98783280 -2.37685704 May 2 0.23331359 -4.61196691 -1.22134668 Jun 2 0.21954602 -6.14729476 -0.47225126 Jul 2 0.19668827 -7.68262261 -0.21406566 Aug 2 0.41625320 -8.68095167 0.26469847 Sep 2 0.46309233 -9.67928073 -2.68381160 Oct 2 -0.07051108 -9.98769336 -5.34179556 Nov 2 0.15952026 -10.29610599 -5.36341427 Dec 2 -0.50753511 -10.15812213 -2.73434276 Jan 3 -0.21580196 -10.02013828 -0.66405976 Feb 3 -0.47350335 -9.66812793 -0.65836873 Mar 3 -0.08575142 -9.31611757 2.10186899 Apr 3 -0.33531016 -8.89658006 2.73189022 May 3 0.23331359 -8.47704255 3.14372896 Jun 3 0.21954602 -8.28893299 2.76938697 Jul 3 0.19668827 -8.10082344 1.10413517 Aug 3 0.41625320 -8.37390562 -0.44234758 Sep 3 0.46309233 -8.64698781 -0.21610452 Oct 3 -0.07051108 -9.32453078 -0.30495814 Nov 3 0.15952026 -10.00207376 1.04255350 Dec 3 -0.50753511 -10.78758090 1.69511601 Jan 4 -0.21580196 -11.57308804 0.28889000 Feb 4 -0.47350335 -12.07752834 1.55103168 Mar 4 -0.08575142 -12.58196863 -2.23227995 Apr 4 -0.33531016 -12.62130262 -3.24338721 May 4 0.23331359 -12.66063662 -1.97267698 Jun 4 0.21954602 -12.22939261 -5.29015342 Jul 4 0.19668827 -11.79814860 -4.09853968 Aug 4 0.41625320 -10.93003420 -2.08621900 Sep 4 0.46309233 -10.06191980 0.19882747 Oct 4 -0.07051108 -8.83752951 0.80804058 Nov 4 0.15952026 -7.61313922 2.05361896 Dec 4 -0.50753511 -6.28138863 2.18892374 Jan 5 -0.21580196 -4.94963805 0.26544001 Feb 5 -0.47350335 -3.84742774 0.32093109 Mar 5 -0.08575142 -2.74521743 -0.26903115 Apr 5 -0.33531016 -2.06684548 1.10215564 May 5 0.23331359 -1.38847352 1.15515993 Jun 5 0.21954602 -1.08068287 0.46113685 Jul 5 0.19668827 -0.77289221 3.57620394 Aug 5 0.41625320 -0.78483536 0.76858216 Sep 5 0.46309233 -0.79677850 1.53368618 Oct 5 -0.07051108 -1.20113564 1.87164671 Nov 5 0.15952026 -1.60549277 0.14597252 Dec 5 -0.50753511 -2.31366725 -0.37879764 Jan 6 -0.21580196 -3.02184172 1.43764368 Feb 6 -0.47350335 -3.70046309 0.57396644 Mar 6 -0.08575142 -4.37908446 0.26483588 Apr 6 -0.33531016 -4.68097804 -1.88371179 May 6 0.23331359 -4.98287162 -3.25044197 Jun 6 0.21954602 -4.83178446 -2.88776157 Jul 6 0.19668827 -4.68069729 -3.71599098 Aug 6 0.41625320 -4.09809716 -3.91815604 Sep 6 0.46309233 -3.51549703 -0.64759530 Oct 6 -0.07051108 -2.51590751 0.88641858 Nov 6 0.15952026 -1.51631799 0.65679773 Dec 6 -0.50753511 -0.31157539 1.01911050 Jan 7 -0.21580196 0.89316721 -0.07736525 Feb 7 -0.47350335 1.94716856 0.72633479 Mar 7 -0.08575142 3.00116991 0.38458151 Apr 7 -0.33531016 3.73988965 1.89542052 May 7 0.23331359 4.47860939 0.78807702 Jun 7 0.21954602 4.96626411 1.11418987 Jul 7 0.19668827 5.45391883 2.04939290 Aug 7 0.41625320 5.68901722 0.39472958 Sep 7 0.46309233 5.92411561 -0.88720794 Oct 7 -0.07051108 5.98488593 0.98562514 Nov 7 0.15952026 6.04565626 -0.50517652 Dec 7 -0.50753511 6.07313589 1.33439922 Jan 8 -0.21580196 6.10061552 0.21518644 Feb 8 -0.47350335 6.04873941 -0.77523606 Mar 8 -0.08575142 5.99686330 -2.21111188 Apr 8 -0.33531016 5.77138883 0.36392134 May 8 0.23331359 5.54591435 1.02077205 Jun 8 0.21954602 5.18983146 3.09062252 Jul 8 0.19668827 4.83374857 2.16956316 Aug 8 0.41625320 4.43940217 0.14434463 Sep 8 0.46309233 4.04505578 0.19185189 Oct 8 -0.07051108 3.51938650 -1.14887542 Nov 8 0.15952026 2.99371721 -0.75323747 Dec 8 -0.50753511 2.30702138 -1.69948627 Jan 9 -0.21580196 1.62032554 0.49547642 Feb 9 -0.47350335 0.78643048 1.38707287 Mar 9 -0.08575142 -0.04746459 2.13321600 Apr 9 -0.33531016 -1.40657767 -0.15811216 May 9 0.23331359 -2.76569076 3.03237717 Jun 9 0.21954602 -4.93496172 3.41541569 Jul 9 0.19668827 -7.10423267 3.60754440 Aug 9 0.41625320 -9.83366372 6.61741052 Sep 9 0.46309233 -12.56309477 4.10000245 Oct 9 -0.07051108 -15.26994041 1.44045149 Nov 9 0.15952026 -17.97678604 -4.08273421 Dec 9 -0.50753511 -20.14122784 -8.15123705 Jan 10 -0.21580196 -22.30566964 -5.07852840 Feb 10 -0.47350335 -23.45662627 -7.46987038 Mar 10 -0.08575142 -24.60758290 -7.10666568 Apr 10 -0.33531016 -24.34472325 -4.71996659 May 10 0.23331359 -24.08186359 -3.75145000 Jun 10 0.21954602 -22.54723826 -1.27230777 Jul 10 0.19668827 -21.01261292 -1.98407535 Aug 10 0.41625320 -18.86997090 0.25371770 Sep 10 0.46309233 -16.72732888 -1.53576345 Oct 10 -0.07051108 -14.60059373 0.47110480 Nov 10 0.15952026 -12.47385857 3.51433831 Dec 10 -0.50753511 -10.82483611 3.43237122 Jan 11 -0.21580196 -9.17581364 2.39161560 Feb 11 -0.47350335 -8.20001373 1.67351708 Mar 11 -0.08575142 -7.22421383 3.70996524 Apr 11 -0.33531016 -6.44936643 4.38467660 May 11 0.23331359 -5.67451904 0.54120545 Jun 11 0.21954602 -4.94202077 -2.97752525 Jul 11 0.19668827 -4.20952250 -2.48716578 Aug 11 0.41625320 -3.54973901 -1.96651419 Sep 11 0.46309233 -2.88995552 -0.97313681 Oct 11 -0.07051108 -2.27357031 -0.45591861 Nov 11 0.15952026 -1.65718510 2.29766485 > m$win s t l 1311 19 13 > m$deg s t l 0 1 1 > m$jump s t l 132 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/freestat/rcomp/tmp/1r1nf1293188539.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/2r1nf1293188539.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/3kb501293188539.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/4kb501293188539.ps",horizontal=F,onefile=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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/59tkt1293188539.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/freestat/rcomp/tmp/6uc0h1293188539.tab") > > try(system("convert tmp/1r1nf1293188539.ps tmp/1r1nf1293188539.png",intern=TRUE)) character(0) > try(system("convert tmp/2r1nf1293188539.ps tmp/2r1nf1293188539.png",intern=TRUE)) character(0) > try(system("convert tmp/3kb501293188539.ps tmp/3kb501293188539.png",intern=TRUE)) character(0) > try(system("convert tmp/4kb501293188539.ps tmp/4kb501293188539.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.805 0.891 1.953