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(108.5,112.3,116.6,115.5,120.1,132.9,128.1,129.3,132.5,131,124.9,120.8,122,122.1,127.4,135.2,137.3,135,136,138.4,134.7,138.4,133.9,133.6,141.2,151.8,155.4,156.6,161.6,160.7,156,159.5,168.7,169.9,169.9,185.9,190.8,195.8,211.9,227.1,251.3,256.7,251.9,251.2,270.3,267.2,243,229.9,187.2,178.2,175.2,192.4,187,184,194.1,212.7,217.5,200.5,205.9,196.5,206.3) > 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 -9.3225733 119.7060 -1.8834137 Feb 1 -12.0994301 120.3370 4.0624093 Mar 1 -8.2558802 120.9681 3.8878257 Apr 1 -1.7548596 121.6465 -4.3916704 May 1 2.7861666 122.3250 -5.0111721 Jun 1 3.8985616 123.0542 5.9472634 Jul 1 1.9709558 123.7833 2.3456996 Aug 1 6.1119050 124.5644 -1.3763177 Sep 1 11.7728603 125.3455 -4.6183410 Oct 1 7.4093969 126.3272 -2.7365565 Nov 1 0.5059251 127.3088 -2.9147636 Dec 1 -3.0230128 128.3065 -4.4835184 Jan 2 -9.3225733 129.3042 2.0183493 Feb 2 -12.0994301 130.0249 4.1745470 Mar 2 -8.2558802 130.7455 4.9103380 Apr 2 -1.7548596 131.3302 5.6246727 May 2 2.7861666 131.9148 2.5990019 Jun 2 3.8985616 132.7585 -1.6570867 Jul 2 1.9709558 133.6022 0.4268253 Aug 2 6.1119050 135.2500 -2.9618806 Sep 2 11.7728603 136.8977 -13.9705925 Oct 2 7.4093969 139.1652 -8.1745828 Nov 2 0.5059251 141.4326 -8.0385647 Dec 2 -3.0230128 143.8881 -7.2651367 Jan 3 -9.3225733 146.3437 4.1789139 Feb 3 -12.0994301 148.7884 15.1110315 Mar 3 -8.2558802 151.2331 12.4227424 Apr 3 -1.7548596 153.7919 4.5629930 May 3 2.7861666 156.3506 2.4632381 Jun 3 3.8985616 159.3597 -2.5583090 Jul 3 1.9709558 162.3689 -8.3398555 Aug 3 6.1119050 166.4697 -13.0816051 Sep 3 11.7728603 170.5705 -13.6433608 Oct 3 7.4093969 176.7254 -14.2348049 Nov 3 0.5059251 182.8803 -13.4862405 Dec 3 -3.0230128 190.9067 -1.9836659 Jan 4 -9.3225733 198.9330 1.1895312 Feb 4 -12.0994301 207.4982 0.4011815 Mar 4 -8.2558802 216.0635 4.0924251 Apr 4 -1.7548596 223.3662 5.4886153 May 4 2.7861666 230.6690 17.8447999 Jun 4 3.8985616 234.3173 18.4841226 Jul 4 1.9709558 237.9656 11.9634460 Aug 4 6.1119050 236.9940 8.0940942 Sep 4 11.7728603 236.0224 22.5047363 Oct 4 7.4093969 231.6835 28.1070612 Nov 4 0.5059251 227.3447 15.1493946 Dec 4 -3.0230128 221.5745 11.3485360 Jan 5 -9.3225733 215.8043 -19.2816999 Feb 5 -12.0994301 210.5196 -20.2201562 Mar 5 -8.2558802 205.2349 -21.7790190 Apr 5 -1.7548596 202.6249 -8.4700564 May 5 2.7861666 200.0149 -15.8010994 Jun 5 3.8985616 199.5826 -19.4811164 Jul 5 1.9709558 199.1502 -7.0211328 Aug 5 6.1119050 199.1353 7.4527963 Sep 5 11.7728603 199.1204 6.6067193 Oct 5 7.4093969 199.5482 -6.4576261 Nov 5 0.5059251 199.9760 5.4180368 Dec 5 -3.0230128 200.7758 -1.2527653 Jan 6 -9.3225733 201.5755 14.0470551 > 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/1dg681259769860.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/2jjwn1259769860.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/3q8k21259769860.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/4zqas1259769860.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/5s8to1259769860.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/67w371259769860.tab") > system("convert tmp/1dg681259769860.ps tmp/1dg681259769860.png") > system("convert tmp/2jjwn1259769860.ps tmp/2jjwn1259769860.png") > system("convert tmp/3q8k21259769860.ps tmp/3q8k21259769860.png") > system("convert tmp/4zqas1259769860.ps tmp/4zqas1259769860.png") > > > proc.time() user system elapsed 0.954 0.604 1.177