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(6802.96,7132.68,7073.29,7264.5,7105.33,7218.71,7225.72,7354.25,7745.46,8070.26,8366.33,8667.51,8854.34,9218.1,9332.9,9358.31,9248.66,9401.2,9652.04,9957.38,10110.63,10169.26,10343.78,10750.21,11337.5,11786.96,12083.04,12007.74,11745.93,11051.51,11445.9,11924.88,12247.63,12690.91,12910.7,13202.12,13654.67,13862.82,13523.93,14211.17,14510.35,14289.23,14111.82,13086.59,13351.54,13747.69,12855.61,12926.93,12121.95,11731.65,11639.51,12163.78,12029.53,11234.18,9852.13,9709.04,9332.75,7108.6,6691.49,6143.05) > 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 95.20134 6462.720 245.038196 Feb 1 221.71887 6645.232 265.729103 Mar 1 140.17029 6827.744 105.376130 Apr 1 392.52092 7014.148 -142.168499 May 1 301.16570 7200.552 -396.387274 Jun 1 10.98714 7386.888 -179.165312 Jul 1 -171.64094 7573.225 -175.863834 Aug 1 -210.71738 7757.304 -192.336710 Sep 1 -47.52572 7941.383 -148.397687 Oct 1 -225.88816 8133.231 162.916853 Nov 1 -327.75528 8325.079 369.006069 Dec 1 -178.23696 8513.308 332.438473 Jan 2 95.20134 8701.538 57.600899 Feb 2 221.71887 8885.233 111.148050 Mar 2 140.17029 9068.928 123.801322 Apr 2 392.52092 9246.288 -280.498900 May 2 301.16570 9423.648 -476.153268 Jun 2 10.98714 9610.067 -219.854475 Jul 2 -171.64094 9796.487 27.193834 Aug 2 -210.71738 10014.459 153.638818 Sep 2 -47.52572 10232.430 -74.274298 Oct 2 -225.88816 10450.552 -55.403862 Nov 2 -327.75528 10668.674 2.861250 Dec 2 -178.23696 10848.788 79.658922 Jan 3 95.20134 11028.902 213.396617 Feb 3 221.71887 11188.424 376.817367 Mar 3 140.17029 11347.945 594.924236 Apr 3 392.52092 11525.259 89.959692 May 3 301.16570 11702.573 -257.808998 Jun 3 10.98714 11890.674 -850.151470 Jul 3 -171.64094 12078.775 -461.234425 Aug 3 -210.71738 12266.469 -130.871509 Sep 3 -47.52572 12454.162 -159.006693 Oct 3 -225.88816 12662.605 254.193619 Nov 3 -327.75528 12871.047 367.408608 Dec 3 -178.23696 13086.360 293.997244 Jan 4 95.20134 13301.673 257.795902 Feb 4 221.71887 13447.753 193.348112 Mar 4 140.17029 13593.833 -210.073557 Apr 4 392.52092 13649.875 168.773968 May 4 301.16570 13705.917 503.267346 Jun 4 10.98714 13666.046 612.196459 Jul 4 -171.64094 13626.176 657.285087 Aug 4 -210.71738 13486.931 -189.624073 Sep 4 -47.52572 13347.687 51.378666 Oct 4 -225.88816 13138.702 834.876124 Nov 4 -327.75528 12929.717 253.648258 Dec 4 -178.23696 12663.389 441.777998 Jan 5 95.20134 12397.061 -370.312241 Feb 5 221.71887 12063.183 -553.251634 Mar 5 140.17029 11729.305 -229.964906 Apr 5 392.52092 11236.240 535.019476 May 5 301.16570 10743.175 985.189712 Jun 5 10.98714 10233.929 989.263795 Jul 5 -171.64094 9724.684 299.087394 Aug 5 -210.71738 9210.031 709.726144 Sep 5 -47.52572 8695.379 684.896795 Oct 5 -225.88816 8165.505 -831.016728 Nov 5 -327.75528 7635.631 -616.385575 Dec 5 -178.23696 7089.924 -768.637211 > m$win s t l 601 19 13 > m$deg s t l 0 1 1 > m$jump s t l 61 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/162oi1259956255.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/20av61259956255.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/33oum1259956255.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/4yek01259956255.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/5q7mb1259956255.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/64uoo1259956255.tab") > system("convert tmp/162oi1259956255.ps tmp/162oi1259956255.png") > system("convert tmp/20av61259956255.ps tmp/20av61259956255.png") > system("convert tmp/33oum1259956255.ps tmp/33oum1259956255.png") > system("convert tmp/4yek01259956255.ps tmp/4yek01259956255.png") > > > proc.time() user system elapsed 0.964 0.605 1.125