R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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(235.1,280.7,264.6,240.7,201.4,240.8,241.1,223.8,206.1,174.7,203.3,220.5,299.5,347.4,338.3,327.7,351.6,396.6,438.8,395.6,363.5,378.8,357,369,464.8,479.1,431.3,366.5,326.3,355.1,331.6,261.3,249,205.5,235.6,240.9,264.9,253.8,232.3,193.8,177,213.2,207.2,180.6,188.6,175.4,199,179.6,225.8,234,200.2,183.6,178.2,203.2,208.5,191.8,172.8,148,159.4,154.5) > 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 34.757117 211.0508 -10.7079115 Feb 1 55.653116 214.4036 10.6432631 Mar 1 29.909118 217.7564 16.9344357 Apr 1 -1.279613 221.5548 20.4248402 May 1 -17.148329 225.3531 -6.8047701 Jun 1 17.731217 229.6530 -6.5841712 Jul 1 21.390759 233.9528 -14.2435681 Aug 1 -12.723028 238.5253 -2.0022362 Sep 1 -26.636793 243.0977 -10.3609262 Oct 1 -45.089897 250.2167 -30.4267601 Nov 1 -29.643008 257.3356 -24.3925880 Dec 1 -26.920631 270.4758 -23.0551715 Jan 2 34.757117 283.6160 -18.8731258 Feb 2 55.653116 299.3081 -7.5612590 Mar 2 29.909118 315.0003 -6.6093942 Apr 2 -1.279613 330.5560 -1.5763455 May 2 -17.148329 346.1116 22.6366884 Jun 2 17.731217 359.5665 19.3023018 Jul 2 21.390759 373.0213 44.3879195 Aug 2 -12.723028 382.5883 25.7346880 Sep 2 -26.636793 392.1554 -2.0185654 Oct 2 -45.089897 395.2600 28.6298945 Nov 2 -29.643008 398.3646 -11.7216397 Dec 2 -26.920631 394.2782 1.6424635 Jan 3 34.757117 390.1917 39.8511959 Feb 3 55.653116 380.7060 42.7408574 Mar 3 29.909118 371.2204 30.1705169 Apr 3 -1.279613 358.7536 9.0260279 May 3 -17.148329 346.2868 -2.8384759 Jun 3 17.731217 331.7232 5.6456203 Jul 3 21.390759 317.1595 -6.9502793 Aug 3 -12.723028 301.2213 -27.1982472 Sep 3 -26.636793 285.2830 -9.6462369 Oct 3 -45.089897 270.8643 -20.2743657 Nov 3 -29.643008 256.4455 8.7975116 Dec 3 -26.920631 245.1023 22.7183772 Jan 4 34.757117 233.7590 -3.6161282 Feb 4 55.653116 225.9410 -27.7941244 Mar 4 29.909118 218.1230 -15.7321227 Apr 4 -1.279613 213.5421 -18.4625366 May 4 -17.148329 208.9613 -14.8129654 Jun 4 17.731217 206.3537 -10.8848944 Jul 4 21.390759 203.7461 -17.9368193 Aug 4 -12.723028 202.2105 -8.8874625 Sep 4 -26.636793 200.6749 14.5618724 Oct 4 -45.089897 199.6171 20.8727805 Nov 4 -29.643008 198.5593 30.0836945 Dec 4 -26.920631 197.6522 8.8684213 Jan 5 34.757117 196.7451 -5.7022228 Feb 5 55.653116 195.5864 -17.2395570 Mar 5 29.909118 194.4278 -24.1368932 Apr 5 -1.279613 193.5909 -8.7113052 May 5 -17.148329 192.7541 2.5942679 Jun 5 17.731217 191.8152 -6.3463855 Jul 5 21.390759 190.8763 -3.7670347 Aug 5 -12.723028 190.1952 14.3277793 Sep 5 -26.636793 189.5142 9.9225714 Oct 5 -45.089897 189.0809 4.0089875 Nov 5 -29.643008 188.6476 0.3954095 Dec 5 -26.920631 188.3204 -6.8997899 > 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/wessaorg/rcomp/tmp/1fbq71322674038.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/249s41322674038.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/3b23i1322674038.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/4eqe31322674038.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/5fal31322674038.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/wessaorg/rcomp/tmp/66vmg1322674038.tab") > > try(system("convert tmp/1fbq71322674038.ps tmp/1fbq71322674038.png",intern=TRUE)) character(0) > try(system("convert tmp/249s41322674038.ps tmp/249s41322674038.png",intern=TRUE)) character(0) > try(system("convert tmp/3b23i1322674038.ps tmp/3b23i1322674038.png",intern=TRUE)) character(0) > try(system("convert tmp/4eqe31322674038.ps tmp/4eqe31322674038.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.245 0.198 1.626