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(1.59,1.26,1.13,1.92,2.61,2.26,2.41,2.26,2.03,2.86,2.55,2.27,2.26,2.57,3.07,2.76,2.51,2.87,3.14,3.11,3.16,2.47,2.57,2.89,2.63,2.38,1.69,1.96,2.19,1.87,1.6,1.63,1.22,1.21,1.49,1.64,1.66,1.77,1.82,1.78,1.28,1.29,1.37,1.12,1.51,2.24,2.94,3.09,3.46,3.64,4.39,4.15,5.21,5.8,5.91,5.39,5.46,4.72,3.14,2.63) > 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.026056506 1.458155 0.157901834 Feb 1 -0.091441321 1.570085 -0.218643800 Mar 1 -0.064826435 1.682016 -0.487189135 Apr 1 0.005693772 1.790397 0.123909317 May 1 0.228213603 1.898778 0.483008145 Jun 1 0.257551633 2.005006 -0.002558056 Jul 1 0.296889667 2.111235 0.001875739 Aug 1 0.065674412 2.216750 -0.022424642 Sep 1 -0.007540997 2.322266 -0.284724868 Oct 1 -0.042954345 2.406130 0.496823925 Nov 1 -0.264367000 2.489995 0.324372026 Dec 1 -0.356837165 2.540987 0.085850567 Jan 2 -0.026056506 2.591978 -0.305921716 Feb 2 -0.091441321 2.637634 0.023807708 Mar 2 -0.064826435 2.683289 0.451537431 Apr 2 0.005693772 2.713386 0.040920051 May 2 0.228213603 2.743483 -0.461696953 Jun 2 0.257551633 2.761248 -0.148799590 Jul 2 0.296889667 2.779013 0.064097767 Aug 2 0.065674412 2.764863 0.279462818 Sep 2 -0.007540997 2.750713 0.416828024 Oct 2 -0.042954345 2.693737 -0.180782575 Nov 2 -0.264367000 2.636761 0.197606133 Dec 2 -0.356837165 2.541599 0.705238146 Jan 3 -0.026056506 2.446437 0.209619334 Feb 3 -0.091441321 2.313941 0.157499902 Mar 3 -0.064826435 2.181446 -0.426619231 Apr 3 0.005693772 2.049922 -0.095615350 May 3 0.228213603 1.918397 0.043388908 Jun 3 0.257551633 1.824180 -0.211731367 Jul 3 0.296889667 1.729962 -0.426851646 Aug 3 0.065674412 1.688312 -0.123986752 Sep 3 -0.007540997 1.646663 -0.419121703 Oct 3 -0.042954345 1.629049 -0.376094971 Nov 3 -0.264367000 1.611436 0.142931068 Dec 3 -0.356837165 1.587065 0.409771839 Jan 4 -0.026056506 1.562695 0.123361785 Feb 4 -0.091441321 1.547778 0.313663101 Mar 4 -0.064826435 1.532862 0.351964715 Apr 4 0.005693772 1.569526 0.204779930 May 4 0.228213603 1.606191 -0.554404479 Jun 4 0.257551633 1.713269 -0.680820307 Jul 4 0.296889667 1.820346 -0.747236140 Aug 4 0.065674412 2.006289 -0.951963496 Sep 4 -0.007540997 2.192232 -0.674690698 Oct 4 -0.042954345 2.466838 -0.183883194 Nov 4 -0.264367000 2.741443 0.462923617 Dec 4 -0.356837165 3.094942 0.351895638 Jan 5 -0.026056506 3.448440 0.037616834 Feb 5 -0.091441321 3.786325 -0.054884021 Mar 5 -0.064826435 4.124211 0.330615423 Apr 5 0.005693772 4.235049 -0.090743142 May 5 0.228213603 4.345888 0.635898670 Jun 5 0.257551633 4.409837 1.132611375 Jul 5 0.296889667 4.473786 1.139324074 Aug 5 0.065674412 4.527734 0.796591949 Sep 5 -0.007540997 4.581681 0.885859978 Oct 5 -0.042954345 4.615665 0.147289473 Nov 5 -0.264367000 4.649649 -1.245281725 Dec 5 -0.356837165 4.661234 -1.674397251 > 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/11trq1259865643.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/2q6oj1259865643.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/385vk1259865643.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/4nyp81259865644.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/5cva61259865644.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/67zhi1259865644.tab") > system("convert tmp/11trq1259865643.ps tmp/11trq1259865643.png") > system("convert tmp/2q6oj1259865643.ps tmp/2q6oj1259865643.png") > system("convert tmp/385vk1259865643.ps tmp/385vk1259865643.png") > system("convert tmp/4nyp81259865644.ps tmp/4nyp81259865644.png") > > > proc.time() user system elapsed 0.973 0.605 1.134