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(102.86,102.55,102.28,102.26,102.57,103.08,102.76,102.51,102.87,103.14,103.12,103.16,102.48,102.57,102.88,102.63,102.38,101.69,101.96,102.19,101.87,101.6,101.63,101.22,101.21,101.49,101.64,101.66,101.77,101.82,101.78,101.28,101.29,101.37,101.12,101.51,102.24,102.94,103.09,103.46,103.64,104.39,104.15,105.21,105.8,105.91,105.39,105.46,104.72,103.14,102.63,102.32,101.93,100.62,100.6,99.63,98.9,98.32,99.22,98.81) > 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.07318921 102.56134 0.225471460 Feb 1 -0.04377718 102.59266 0.001112589 Mar 1 -0.03074394 102.62399 -0.313245914 Apr 1 -0.02093190 102.65112 -0.370184018 May 1 0.01888006 102.67824 -0.127122056 Jun 1 -0.06894992 102.70078 0.448165216 Jul 1 -0.08878005 102.72333 0.125452636 Aug 1 -0.09993614 102.74574 -0.135799621 Sep 1 -0.04309245 102.76814 0.144948344 Oct 1 -0.01386321 102.77627 0.377590574 Nov 1 0.12136560 102.78440 0.214233245 Dec 1 0.19664012 102.73555 0.227806442 Jan 2 0.07318921 102.68671 -0.279894941 Feb 2 -0.04377718 102.60764 0.006139417 Mar 2 -0.03074394 102.52857 0.382174142 Apr 2 -0.02093190 102.42176 0.229174480 May 2 0.01888006 102.31495 0.046174884 Jun 2 -0.06894992 102.18837 -0.429419631 Jul 2 -0.08878005 102.06179 -0.013013999 Aug 2 -0.09993614 101.94814 0.341792864 Sep 2 -0.04309245 101.83449 0.078599949 Oct 2 -0.01386321 101.75801 -0.144149713 Nov 2 0.12136560 101.68153 -0.172898935 Dec 2 0.19664012 101.64674 -0.623380049 Jan 3 0.07318921 101.61195 -0.475135743 Feb 3 -0.04377718 101.58804 -0.054259535 Mar 3 -0.03074394 101.56413 0.106617039 Apr 3 -0.02093190 101.54983 0.131104664 May 3 0.01888006 101.53553 0.215592356 Jun 3 -0.06894992 101.55311 0.335838830 Jul 3 -0.08878005 101.57069 0.298085452 Aug 3 -0.09993614 101.64402 -0.264082006 Sep 3 -0.04309245 101.71734 -0.384249243 Oct 3 -0.01386321 101.85477 -0.470902007 Nov 3 0.12136560 101.99219 -0.993554331 Dec 3 0.19664012 102.20852 -0.895159558 Jan 4 0.07318921 102.42485 -0.258039364 Feb 4 -0.04377718 102.74239 0.241383832 Mar 4 -0.03074394 103.05994 0.060807396 Apr 4 -0.02093190 103.43009 0.050837121 May 4 0.01888006 103.80025 -0.179133088 Jun 4 -0.06894992 104.09502 0.363929479 Jul 4 -0.08878005 104.38979 -0.151007807 Aug 4 -0.09993614 104.49399 0.815943876 Sep 4 -0.04309245 104.59820 1.244895782 Oct 4 -0.01386321 104.50244 1.421425829 Nov 4 0.12136560 104.40668 0.861956318 Dec 4 0.19664012 104.11480 1.148561789 Jan 5 0.07318921 103.82292 0.823892680 Feb 5 -0.04377718 103.34484 -0.161063771 Mar 5 -0.03074394 102.86676 -0.206019855 Apr 5 -0.02093190 102.29829 0.042638044 May 5 0.01888006 101.72982 0.181296010 Jun 5 -0.06894992 101.17940 -0.490447299 Jul 5 -0.08878005 100.62897 0.059809540 Aug 5 -0.09993614 100.07774 -0.347803459 Sep 5 -0.04309245 99.52651 -0.583416236 Oct 5 -0.01386321 98.97694 -0.643077144 Nov 5 0.12136560 98.42737 0.671262388 Dec 5 0.19664012 97.88311 0.730252983 > 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/1uznt1260464859.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/2dz3a1260464859.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/359pj1260464859.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/4yrqw1260464859.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/551251260464859.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/6ojhu1260464859.tab") > system("convert tmp/1uznt1260464859.ps tmp/1uznt1260464859.png") > system("convert tmp/2dz3a1260464859.ps tmp/2dz3a1260464859.png") > system("convert tmp/359pj1260464859.ps tmp/359pj1260464859.png") > system("convert tmp/4yrqw1260464859.ps tmp/4yrqw1260464859.png") > > > proc.time() user system elapsed 1.004 0.618 2.166