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(11.1,10.9,10,9.2,9.2,9.5,9.6,9.5,9.1,8.9,9,10.1,10.3,10.2,9.6,9.2,9.3,9.4,9.4,9.2,9,9,9,9.8,10,9.8,9.3,9,9,9.1,9.1,9.1,9.2,8.8,8.3,8.4,8.1,7.7,7.9,7.9,8,7.9,7.6,7.1,6.8,6.5,6.9,8.2,8.7,8.3,7.9,7.5,7.8,8.3,8.4,8.2,7.7,7.2,7.3,8.1) > 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.72458343 9.984172 0.39124459 Feb 1 0.49876397 9.924242 0.47699429 Mar 1 0.09294463 9.864312 0.04274386 Apr 1 -0.25266994 9.811122 -0.35845250 May 1 -0.11828474 9.757933 -0.43964862 Jun 1 0.08883857 9.707182 -0.29602102 Jul 1 0.09596198 9.656432 -0.15239350 Aug 1 -0.07567272 9.607560 -0.03188729 Sep 1 -0.30730720 9.558688 -0.15138129 Oct 1 -0.56062595 9.543096 -0.08246966 Nov 1 -0.51394487 9.527503 -0.01355786 Dec 1 0.32741286 9.521922 0.25066527 Jan 2 0.72458343 9.516341 0.05907555 Feb 2 0.49876397 9.501552 0.19968442 Mar 2 0.09294463 9.486762 0.02029317 Apr 2 -0.25266994 9.472816 -0.02014647 May 2 -0.11828474 9.458871 -0.04058587 Jun 2 0.08883857 9.441287 -0.13012603 Jul 2 0.09596198 9.423704 -0.11966628 Aug 2 -0.07567272 9.403669 -0.12799646 Sep 2 -0.30730720 9.383634 -0.07632684 Oct 2 -0.56062595 9.364637 0.19598933 Nov 2 -0.51394487 9.345639 0.16830567 Dec 2 0.32741286 9.324529 0.14805820 Jan 3 0.72458343 9.303419 -0.02800213 Feb 3 0.49876397 9.284450 0.01678627 Mar 3 0.09294463 9.265481 -0.05842545 Apr 3 -0.25266994 9.233761 0.01890921 May 3 -0.11828474 9.202041 -0.08375590 Jun 3 0.08883857 9.116279 -0.10511790 Jul 3 0.09596198 9.030518 -0.02647999 Aug 3 -0.07567272 8.899260 0.27641260 Sep 3 -0.30730720 8.768002 0.73930497 Oct 3 -0.56062595 8.639263 0.72136262 Nov 3 -0.51394487 8.510524 0.30342045 Dec 3 0.32741286 8.380577 -0.30798941 Jan 4 0.72458343 8.250629 -0.87521212 Feb 4 0.49876397 8.095389 -0.89415328 Mar 4 0.09294463 7.940150 -0.13309456 Apr 4 -0.25266994 7.807966 0.34470421 May 4 -0.11828474 7.675782 0.44250322 Jun 4 0.08883857 7.631296 0.17986583 Jul 4 0.09596198 7.586810 -0.08277166 Aug 4 -0.07567272 7.589762 -0.41408905 Sep 4 -0.30730720 7.592714 -0.48540665 Oct 4 -0.56062595 7.597085 -0.53645927 Nov 4 -0.51394487 7.601457 -0.18751173 Dec 4 0.32741286 7.642214 0.23037291 Jan 5 0.72458343 7.682972 0.29244470 Feb 5 0.49876397 7.757891 0.04334465 Mar 5 0.09294463 7.832811 -0.02575552 Apr 5 -0.25266994 7.862667 -0.10999662 May 5 -0.11828474 7.892522 0.02576252 Jun 5 0.08883857 7.914069 0.29709283 Jul 5 0.09596198 7.935615 0.36842304 Aug 5 -0.07567272 7.954906 0.32076686 Sep 5 -0.30730720 7.974197 0.03311046 Oct 5 -0.56062595 7.988470 -0.22784412 Nov 5 -0.51394487 8.002743 -0.18879853 Dec 5 0.32741286 8.012015 -0.23942787 > 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/12p391259846874.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/2xat61259846874.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/3lifn1259846874.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/4jh7m1259846874.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/5qen21259846874.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/6o7rq1259846874.tab") > > system("convert tmp/12p391259846874.ps tmp/12p391259846874.png") > system("convert tmp/2xat61259846874.ps tmp/2xat61259846874.png") > system("convert tmp/3lifn1259846874.ps tmp/3lifn1259846874.png") > system("convert tmp/4jh7m1259846874.ps tmp/4jh7m1259846874.png") > > > proc.time() user system elapsed 0.974 0.612 1.321