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(562,561,555,544,537,543,594,611,613,611,594,595,591,589,584,573,567,569,621,629,628,612,595,597,593,590,580,574,573,573,620,626,620,588,566,557,561,549,532,526,511,499,555,565,542,527,510,514,517,508,493,490,469,478,528,534,518,506,502,516,528) > 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.6908252 558.3822 -0.07305895 Feb 1 -3.7599243 561.5199 3.24003570 Mar 1 -13.5951789 564.6575 3.93763537 Apr 1 -20.2371238 567.7757 -3.53856152 May 1 -29.4790644 570.8938 -4.41476265 Jun 1 -27.9471389 573.9184 -2.97125073 Jul 1 23.7847915 576.9430 -6.72774378 Aug 1 33.8421521 579.8327 -2.67482393 Sep 1 25.6995137 582.7224 4.57809492 Oct 1 11.1796329 585.4186 14.40174054 Nov 1 -3.3402441 588.1149 9.22538230 Dec 1 0.1617536 590.1982 4.64002626 Jan 2 3.6908252 592.2816 -4.97240363 Feb 2 -3.7599243 593.5445 -0.78453474 Mar 2 -13.5951789 594.8073 2.78783916 Apr 2 -20.2371238 595.3835 -2.14633735 May 2 -29.4790644 595.9596 0.51948191 Jun 2 -27.9471389 596.2411 0.70599748 Jul 2 23.7847915 596.5227 0.69250806 Aug 2 33.8421521 596.5807 -1.42287843 Sep 2 25.6995137 596.6388 5.66173408 Oct 2 11.1796329 596.6207 4.19971617 Nov 2 -3.3402441 596.6025 1.73769439 Dec 2 0.1617536 596.6207 0.21758716 Jan 3 3.6908252 596.6388 -7.32959392 Feb 3 -3.7599243 596.2726 -2.51270004 Mar 3 -13.5951789 595.9065 -2.31130115 Apr 3 -20.2371238 594.5549 -0.31777807 May 3 -29.4790644 593.2033 9.27574077 Jun 3 -27.9471389 590.6771 10.27004772 Jul 3 23.7847915 588.1509 8.06434969 Aug 3 33.8421521 584.4626 7.69524699 Sep 3 25.6995137 580.7743 13.52614330 Oct 3 11.1796329 575.9606 0.85972359 Nov 3 -3.3402441 571.1469 -1.80669998 Dec 3 0.1617536 565.5660 -8.72775499 Jan 4 3.6908252 559.9851 -2.67588386 Feb 4 -3.7599243 554.4197 -1.65974635 Mar 4 -13.5951789 548.8543 -3.25910383 Apr 4 -20.2371238 543.8665 2.37061002 May 4 -29.4790644 538.8787 1.60031964 Jun 4 -27.9471389 534.7462 -7.79906683 Jul 4 23.7847915 530.6137 0.60154171 Aug 4 33.8421521 527.0898 4.06802524 Sep 4 25.6995137 523.5660 -7.26549223 Oct 4 11.1796329 520.5365 -4.71611313 Nov 4 -3.3402441 517.5070 -4.16673789 Dec 4 0.1617536 515.0385 -1.20022694 Jan 5 3.6908252 512.5700 0.73921016 Feb 5 -3.7599243 510.5004 1.25955247 Mar 5 -13.5951789 508.4308 -1.83560020 Apr 5 -20.2371238 507.2303 3.00681465 May 5 -29.4790644 506.0298 -7.55077474 Jun 5 -27.9471389 506.0328 -0.08570634 Jul 5 23.7847915 506.0359 -1.82064292 Aug 5 33.8421521 506.1474 -5.98951920 Sep 5 25.6995137 506.2589 -13.95839648 Oct 5 11.1796329 506.4309 -11.61056147 Nov 5 -3.3402441 506.6030 -1.26273032 Dec 5 0.1617536 506.9482 8.89003032 Jan 6 3.6908252 507.2935 17.01571710 > 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/15j381259934136.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/2jjqr1259934136.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/3jn1f1259934136.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/4n37m1259934136.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/529ho1259934136.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/6ktsh1259934136.tab") > system("convert tmp/15j381259934136.ps tmp/15j381259934136.png") > system("convert tmp/2jjqr1259934136.ps tmp/2jjqr1259934136.png") > system("convert tmp/3jn1f1259934136.ps tmp/3jn1f1259934136.png") > system("convert tmp/4n37m1259934136.ps tmp/4n37m1259934136.png") > > > proc.time() user system elapsed 0.976 0.637 1.190