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(226.9,235.9,216.2,226.2,198.3,176.7,166.2,157.6,163.4,159.7,191.0,239.4,321.9,362.7,413.6,407.1,383.2,347.7,333.8,312.3,295.4,283.3,287.6,265.7,250.2,234.7,244.0,231.2,223.8,223.5,210.5,201.6,190.7,207.5,198.8,196.6,204.2,227.4,229.7,217.9,221.4,216.3,197.0,193.8,196.8,180.5,174.8,181.6,190.0,190.6,179.0,174.1,161.1,168.6,169.4,152.2,148.3,137.7,145.0,153.4) > 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 17.2474664 171.8107 37.8418322 Feb 1 28.0506694 176.7649 31.0844665 Mar 1 33.4738883 181.7190 1.0070851 Apr 1 27.0883237 187.9102 11.2014449 May 1 12.1627724 194.1014 -7.9642084 Jun 1 0.9261102 201.4200 -25.6461259 Jul 1 -10.4905555 208.7386 -32.0480399 Aug 1 -21.1284566 216.8122 -38.0837254 Sep 1 -24.4663640 224.8858 -37.0194045 Oct 1 -28.3649927 237.9336 -49.8685758 Nov 1 -21.3836383 250.9814 -38.5977301 Dec 1 -13.1151675 267.7641 -15.2488881 Jan 2 17.2474664 284.5467 20.1057909 Feb 2 28.0506694 298.8951 35.7542183 Mar 2 33.4738883 313.2435 66.8826300 Apr 2 27.0883237 322.2153 57.7964225 May 2 12.1627724 331.1870 39.8502019 Jun 2 0.9261102 331.0497 15.7241405 Jul 2 -10.4905555 330.9125 13.3780827 Aug 2 -21.1284566 321.2196 12.2088230 Sep 2 -24.4663640 311.5268 8.3395696 Oct 2 -28.3649927 297.7217 13.9432789 Nov 2 -21.3836383 283.9166 25.0670051 Dec 2 -13.1151675 271.4012 7.4139318 Jan 3 17.2474664 258.8858 -25.9333046 Feb 3 28.0506694 248.9602 -42.3108958 Mar 3 33.4738883 239.0346 -28.5085028 Apr 3 27.0883237 232.1212 -28.0095530 May 3 12.1627724 225.2078 -13.5706163 Jun 3 0.9261102 221.3255 1.2483572 Jul 3 -10.4905555 217.4432 3.5473342 Aug 3 -21.1284566 215.7391 6.9893458 Sep 3 -24.4663640 214.0350 1.1313638 Oct 3 -28.3649927 212.7144 23.1505752 Nov 3 -21.3836383 211.3938 8.7898036 Dec 3 -13.1151675 210.1248 -0.4096404 Jan 4 17.2474664 208.8558 -21.9032476 Feb 4 28.0506694 207.9267 -8.5773987 Mar 4 33.4738883 206.9977 -10.7715656 Apr 4 27.0883237 206.3061 -15.4943801 May 4 12.1627724 205.6144 3.6227922 Jun 4 0.9261102 204.6646 10.7092641 Jul 4 -10.4905555 203.7148 3.7757396 Aug 4 -21.1284566 201.2514 13.6770666 Sep 4 -24.4663640 198.7880 22.4784001 Oct 4 -28.3649927 194.3736 14.4914301 Nov 4 -21.3836383 189.9592 6.2244772 Dec 4 -13.1151675 185.1541 9.5610731 Jan 5 17.2474664 180.3490 -7.5964941 Feb 5 28.0506694 176.3593 -13.8099988 Mar 5 33.4738883 172.3696 -26.8435193 Apr 5 27.0883237 170.9836 -23.9719002 May 5 12.1627724 169.5975 -20.6602942 Jun 5 0.9261102 168.3300 -0.6561434 Jul 5 -10.4905555 167.0625 12.8280110 Aug 5 -21.1284566 166.2411 7.0873899 Sep 5 -24.4663640 165.4196 7.3467751 Oct 5 -28.3649927 165.0017 1.0632685 Nov 5 -21.3836383 164.5839 1.7997789 Dec 5 -13.1151675 164.3846 2.1305346 > 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/1jmex1260004534.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/28dzk1260004534.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/3moqs1260004534.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/4iky31260004534.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/5ol7b1260004534.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/6j05b1260004534.tab") > system("convert tmp/1jmex1260004534.ps tmp/1jmex1260004534.png") > system("convert tmp/28dzk1260004534.ps tmp/28dzk1260004534.png") > system("convert tmp/3moqs1260004534.ps tmp/3moqs1260004534.png") > system("convert tmp/4iky31260004534.ps tmp/4iky31260004534.png") > > > proc.time() user system elapsed 0.949 0.610 1.260