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.1,102.86,102.99,103.73,105.02,104.43,104.63,104.93,105.87,105.66,106.76,106,107.22,107.33,107.11,108.86,107.72,107.88,108.38,107.72,108.41,109.9,111.45,112.18,113.34,113.46,114.06,115.54,116.39,115.94,116.97,115.94,115.91,116.43,116.26,116.35,117.9,117.7,117.53,117.86,117.65,116.51,115.93,115.31,115) > 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.30636470 102.1757 -0.38210412 Feb 1 0.20755632 102.6131 0.03931288 Mar 1 -0.00375183 103.0505 -0.05677035 Apr 1 0.80624954 103.4768 -0.55305628 May 1 0.73874988 103.9031 0.37815882 Jun 1 -0.01806852 104.3184 0.12971142 Jul 1 0.01761322 104.7336 -0.12123612 Aug 1 -0.74262547 105.1418 0.53085664 Sep 1 -0.67786375 105.5499 0.99794899 Oct 1 -0.37816354 105.9096 0.12852437 Nov 1 0.03958579 106.2694 0.45105063 Dec 1 -0.29564743 106.5444 -0.24870820 Jan 2 0.30636470 106.8193 0.09428762 Feb 2 0.20755632 107.0718 0.05068814 Mar 2 -0.00375183 107.3242 -0.21041157 Apr 2 0.80624954 107.6426 0.41117837 May 2 0.73874988 107.9610 -0.97973067 Jun 2 -0.01806852 108.4059 -0.50785575 Jul 2 0.01761322 108.8509 -0.48848098 Aug 2 -0.74262547 109.3993 -0.93666656 Sep 2 -0.67786375 109.9477 -0.85985255 Oct 2 -0.37816354 110.5833 -0.30518373 Nov 2 0.03958579 111.2190 0.19143597 Dec 2 -0.29564743 111.9176 0.55805431 Jan 3 0.30636470 112.6162 0.41742731 Feb 3 0.20755632 113.2831 -0.03064683 Mar 3 -0.00375183 113.9500 0.11377880 Apr 3 0.80624954 114.4846 0.24912047 May 3 0.73874988 115.0193 0.63196318 Jun 3 -0.01806852 115.4162 0.54183938 Jul 3 0.01761322 115.8132 1.13921546 Aug 3 -0.74262547 116.1166 0.56605412 Sep 3 -0.67786375 116.4200 0.16789238 Oct 3 -0.37816354 116.6045 0.20370919 Nov 3 0.03958579 116.7889 -0.56852312 Dec 3 -0.29564743 116.8062 -0.16053748 Jan 4 0.30636470 116.8234 0.77020282 Feb 4 0.20755632 116.7626 0.72987754 Mar 4 -0.00375183 116.7017 0.83205204 Apr 4 0.80624954 116.6388 0.41497093 May 4 0.73874988 116.5759 0.33539085 Jun 4 -0.01806852 116.5023 0.02581207 Jul 4 0.01761322 116.4287 -0.51626684 Aug 4 -0.74262547 116.3390 -0.28636978 Sep 4 -0.67786375 116.2493 -0.57147313 > m$win s t l 451 19 13 > m$deg s t l 0 1 1 > m$jump s t l 46 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1gkn71260548419.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/2zajq1260548419.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/3r1tn1260548419.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/45y1w1260548419.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/5uk8a1260548419.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/6vk4a1260548419.tab") > > system("convert tmp/1gkn71260548419.ps tmp/1gkn71260548419.png") > system("convert tmp/2zajq1260548419.ps tmp/2zajq1260548419.png") > system("convert tmp/3r1tn1260548419.ps tmp/3r1tn1260548419.png") > system("convert tmp/45y1w1260548419.ps tmp/45y1w1260548419.png") > > > proc.time() user system elapsed 0.911 0.603 1.943