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(130,136.7,138.1,139.5,140.4,144.6,151.4,147.9,141.5,143.8,143.6,150.5,150.1,154.9,162.1,176.7,186.6,194.8,196.3,228.8,267.2,237.2,254.7,258.2,257.9,269.6,266.9,269.6,253.9,258.6,274.2,301.5,304.5,285.1,287.7,265.5,264.1,276.1,258.9,239.1,250.1,276.8,297.6,295.4,283,275.8,279.7,254.6,234.6,176.9,148.1,122.7,124.9,121.6,128.4,144.5,151.8,167.1,173.8,203.7,199.8) > 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 6.026860 144.5587 -20.5855726 Feb 1 -6.271840 144.5317 -1.5598603 Mar 1 -14.148020 144.5047 7.7433321 Apr 1 -20.194201 144.6222 15.0719734 May 1 -19.280389 144.7398 14.9406229 Jun 1 -12.271861 145.2197 11.6522029 Jul 1 -3.063336 145.6996 8.7637849 Aug 1 10.915721 146.4292 -9.4448767 Sep 1 16.834774 147.1588 -22.4935347 Oct 1 9.662738 148.7088 -14.5714920 Nov 1 16.390717 150.2587 -23.0494648 Dec 1 15.398866 155.0462 -19.9451106 Jan 2 6.026860 159.8337 -15.7606007 Feb 2 -6.271840 167.3026 -6.1307640 Mar 2 -14.148020 174.7715 1.4765528 Apr 2 -20.194201 183.8333 13.0608959 May 2 -19.280389 192.8951 12.9852471 Jun 2 -12.271861 201.9297 5.1421497 Jul 2 -3.063336 210.9643 -11.6009457 Aug 2 10.915721 219.3947 -1.5103804 Sep 2 16.834774 227.8250 22.5401887 Oct 2 9.662738 235.3311 -7.7938184 Nov 2 16.390717 242.8371 -4.5278411 Dec 2 15.398866 249.1784 -6.3773027 Jan 3 6.026860 255.5197 -3.6466086 Feb 3 -6.271840 260.7536 15.1182362 Mar 3 -14.148020 265.9875 15.0605611 Apr 3 -20.194201 269.5154 20.2787887 May 3 -19.280389 273.0434 0.1370244 Jun 3 -12.271861 274.3686 -3.4967878 Jul 3 -3.063336 275.6939 1.5694019 Aug 3 10.915721 275.2589 15.3254286 Sep 3 16.834774 274.8238 12.8414590 Oct 3 9.662738 273.9425 1.4947241 Nov 3 16.390717 273.0613 -1.7520264 Dec 3 15.398866 273.0218 -22.9206822 Jan 4 6.026860 272.9823 -14.9091822 Feb 4 -6.271840 273.1594 9.2124867 Mar 4 -14.148020 273.3364 -0.2883644 Apr 4 -20.194201 273.2314 -13.9372105 May 4 -19.280389 273.1264 -3.7460485 Jun 4 -12.271861 271.3844 17.6875112 Jul 4 -3.063336 269.6423 31.0210729 Aug 4 10.915721 263.8163 20.6679536 Sep 4 16.834774 257.9904 8.1748379 Oct 4 9.662738 247.7208 18.4164798 Nov 4 16.390717 237.4512 25.8581061 Dec 4 15.398866 224.3239 14.8772509 Jan 5 6.026860 211.1966 17.3765515 Feb 5 -6.271840 198.0243 -14.8524701 Mar 5 -14.148020 184.8520 -22.6040116 Apr 5 -20.194201 176.9024 -34.0082050 May 5 -19.280389 168.9528 -24.7723904 Jun 5 -12.271861 165.9182 -32.0463240 Jul 5 -3.063336 162.8836 -31.4202556 Aug 5 10.915721 160.4044 -26.8201046 Sep 5 16.834774 157.9252 -22.9599499 Oct 5 9.662738 156.2972 1.1400193 Nov 5 16.390717 154.6693 2.7399730 Dec 5 15.398866 154.1189 34.1822282 Jan 6 6.026860 153.5685 40.2046391 > 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/10swe1259928509.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/2jwe51259928509.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/3sj5r1259928509.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/4r7ur1259928509.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/5e1n81259928509.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/62yib1259928509.tab") > system("convert tmp/10swe1259928509.ps tmp/10swe1259928509.png") > system("convert tmp/2jwe51259928509.ps tmp/2jwe51259928509.png") > system("convert tmp/3sj5r1259928509.ps tmp/3sj5r1259928509.png") > system("convert tmp/4r7ur1259928509.ps tmp/4r7ur1259928509.png") > > > proc.time() user system elapsed 0.943 0.592 2.290