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(162,161,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) > 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 21.061784 139.0471 1.89107791 Feb 1 20.409456 138.2751 2.31539594 Mar 1 10.009825 137.5032 1.48701653 Apr 1 1.480135 136.8253 0.69454041 May 1 -1.249556 136.1475 0.10206467 Jun 1 -2.756109 135.5524 -2.79627137 Jul 1 -5.462663 134.9573 -2.49460578 Aug 1 -9.935553 134.4011 -2.46552206 Sep 1 -12.408442 133.8449 -4.43643997 Oct 1 -18.567697 133.5588 -2.99115095 Nov 1 -16.926954 133.2728 -3.34586069 Dec 1 14.345780 133.1464 1.50777236 Jan 2 21.061784 133.0201 2.91813530 Feb 2 20.409456 132.7703 3.82021382 Mar 2 10.009825 132.5206 4.46959491 Apr 2 1.480135 132.1585 3.36140922 May 2 -1.249556 131.7963 1.45322391 Jun 2 -2.756109 131.2559 -3.49982015 Jul 2 -5.462663 130.7155 -2.25286260 Aug 2 -9.935553 129.9722 -3.03661391 Sep 2 -12.408442 129.2288 -2.82036684 Oct 2 -18.567697 128.3490 1.21868735 Nov 2 -16.926954 127.4692 1.45774279 Dec 2 14.345780 126.5386 3.11564229 Jan 3 21.061784 125.6079 3.33027168 Feb 3 20.409456 124.5043 4.08622729 Mar 3 10.009825 123.4007 0.58948547 Apr 3 1.480135 121.9808 -0.46095672 May 3 -1.249556 120.5610 -3.31139853 Jun 3 -2.756109 118.8978 0.85826234 Jul 3 -5.462663 117.2347 -0.77207517 Aug 3 -9.935553 115.5637 -0.62813255 Sep 3 -12.408442 113.8926 0.51580845 Oct 3 -18.567697 112.4967 1.07100780 Nov 3 -16.926954 111.1007 -1.17379162 Dec 3 14.345780 110.0416 -0.38735959 Jan 4 21.061784 108.9824 -0.04419768 Feb 4 20.409456 108.1549 -4.56436782 Mar 4 10.009825 107.3274 -2.33723540 Apr 4 1.480135 106.6618 -2.14193689 May 4 -1.249556 105.9962 0.25336199 Jun 4 -2.756109 105.4162 2.33991387 Jul 4 -5.462663 104.8362 1.62646736 Aug 4 -9.935553 104.2809 0.65470052 Sep 4 -12.408442 103.7255 1.68293206 Oct 4 -18.567697 103.4102 -0.84254394 Nov 4 -16.926954 103.0950 0.83198131 Dec 4 14.345780 103.3282 -1.67398594 Jan 5 21.061784 103.5614 -4.62322330 Feb 5 20.409456 104.4852 -7.89467476 Mar 5 10.009825 105.4090 -6.41882365 Apr 5 1.480135 106.9362 -3.41633689 May 5 -1.249556 108.4634 -0.21384976 Jun 5 -2.756109 110.0211 1.73497773 Jul 5 -5.462663 111.5789 2.88380684 Aug 5 -9.935553 113.1910 4.74455125 Sep 5 -12.408442 114.8031 4.60529405 Oct 5 -18.567697 116.4513 1.11637693 Nov 5 -16.926954 118.0995 1.82746105 Dec 5 14.345780 119.7183 -3.06407619 Jan 6 21.061784 121.3371 -5.39888354 > 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/1zlmh1259853087.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/2bb0j1259853087.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/394191259853087.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/401ki1259853087.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/58hs71259853087.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/6m6341259853087.tab") > system("convert tmp/1zlmh1259853087.ps tmp/1zlmh1259853087.png") > system("convert tmp/2bb0j1259853087.ps tmp/2bb0j1259853087.png") > system("convert tmp/394191259853087.ps tmp/394191259853087.png") > system("convert tmp/401ki1259853087.ps tmp/401ki1259853087.png") > > > proc.time() user system elapsed 0.947 0.585 1.444