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(519,517,510,509,501,507,569,580,578,565,547,555,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) > par8 = 'TRUE' > 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.191953 518.1030 -0.2949334 Feb 1 -3.693793 521.7488 -1.0550527 Mar 1 -13.782440 525.3947 -1.6122704 Apr 1 -19.617221 528.9967 -0.3794433 May 1 -31.810130 532.5986 0.2115114 Jun 1 -28.928090 536.1640 -0.2359191 Jul 1 24.378971 539.7294 4.8916289 Aug 1 34.705525 543.2884 2.0060706 Sep 1 29.915924 546.8474 1.2366674 Oct 1 13.952958 550.1732 0.8738863 Nov 1 -4.843941 553.4989 -1.6549624 Dec 1 -1.469719 556.2798 0.1899324 Jan 2 1.191953 559.0607 1.7473778 Feb 2 -3.693793 561.6576 3.0362409 Mar 2 -13.782440 564.2544 4.5280056 Apr 2 -19.617221 566.8844 -3.2671465 May 2 -31.810130 569.5143 -0.7041710 Jun 2 -28.928090 572.1855 -0.2574115 Jul 2 24.378971 574.8567 -5.2356735 Aug 2 34.705525 577.4014 -1.1069360 Sep 2 29.915924 579.9461 3.1379567 Oct 2 13.952958 582.3700 14.6770338 Nov 2 -4.843941 584.7939 14.0500432 Dec 2 -1.469719 587.0974 9.3723539 Jan 3 1.191953 589.4008 0.4072151 Feb 3 -3.693793 591.3712 1.3226144 Mar 3 -13.782440 593.3415 4.4409154 Apr 3 -19.617221 594.4086 -1.7913365 May 3 -31.810130 595.4756 3.3345392 Jun 3 -28.928090 595.8992 2.0288677 Jul 3 24.378971 596.3229 0.2981747 Aug 3 34.705525 596.3954 -2.1009739 Sep 3 29.915924 596.4680 1.6160327 Oct 3 13.952958 596.2495 1.7975431 Nov 3 -4.843941 596.0310 3.8129859 Dec 3 -1.469719 595.6144 2.8553650 Jan 4 1.191953 595.1978 -3.3897053 Feb 4 -3.693793 593.8322 -0.1384218 Mar 4 -13.782440 592.4667 1.3157634 Apr 4 -19.617221 589.4577 4.1594830 May 4 -31.810130 586.4488 18.3613302 Jun 4 -28.928090 583.3413 18.5868240 Jul 4 24.378971 580.2337 15.3872963 Aug 4 34.705525 577.0867 14.2077369 Sep 4 29.915924 573.9397 16.1443326 Oct 4 13.952958 570.6921 3.3549005 Nov 4 -4.843941 567.4445 3.3994008 Dec 4 -1.469719 562.9627 -4.4929349 Jan 5 1.191953 558.4808 1.3272801 Feb 5 -3.693793 553.8118 -1.1179998 Mar 5 -13.782440 549.1428 -3.3603781 Apr 5 -19.617221 544.7189 0.8983421 May 5 -31.810130 540.2949 2.5151900 Jun 5 -28.928090 536.4470 -8.5188792 Jul 5 24.378971 532.5990 -1.9779699 Aug 5 34.705525 529.1579 1.1365924 Sep 5 29.915924 525.7168 -13.6326901 Oct 5 13.952958 522.5563 -9.5092196 Nov 5 -4.843941 519.3958 -4.5518166 Dec 5 -1.469719 516.6492 -1.1794649 Jan 6 1.191953 513.9026 1.9054374 Feb 6 -3.693793 511.5585 0.1352931 Mar 6 -13.782440 509.2144 -2.4319495 Apr 6 -19.617221 506.9275 2.6897263 May 6 -31.810130 504.6406 -3.8304702 Jun 6 -28.928090 502.3262 4.6018616 Jul 6 24.378971 500.0119 3.6091719 Aug 6 34.705525 497.6877 1.6068035 Sep 6 29.915924 495.3635 -7.2794098 Oct 6 13.952958 492.9930 -0.9459258 Nov 6 -4.843941 490.6225 16.2214906 Dec 6 -1.469719 488.2149 29.2548517 > m$win s t l 721 19 13 > m$deg s t l 0 1 1 > m$jump s t l 73 2 2 > m$inner [1] 1 > m$outer [1] 15 > postscript(file="/var/www/html/rcomp/tmp/1gnzy1243878181.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/2jfy21243878181.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/3ppg41243878181.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/42dym1243878181.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/5y4h21243878181.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/6vwrj1243878181.tab") > > system("convert tmp/1gnzy1243878181.ps tmp/1gnzy1243878181.png") > system("convert tmp/2jfy21243878181.ps tmp/2jfy21243878181.png") > system("convert tmp/3ppg41243878181.ps tmp/3ppg41243878181.png") > system("convert tmp/42dym1243878181.ps tmp/42dym1243878181.png") > > > proc.time() user system elapsed 0.990 0.603 1.188