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(16.2,16.7,18.4,16,16.5,18.2,16.8,17.3,18,19.6,23.3,23.7,20.3,22.8,24.3,21.5,23.5,22.2,20.9,22.2,19.5,21.1,22,19.2,17.8,19.2,19.9,19.6,18.1,20.4,18.1,18.6,17.6,19.4,19.3,18.6,16.9,16.4,19,18.7,17.1,21.5,17.8,18.1,19,18.9,16.8,18.1,15.7,15.1,18.3,16.5,16.9,18.4,16.4,15.7,16.9,16.6,16.7,16.6) > 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 -1.2407906 15.88788 1.552910633 Feb 1 -0.6456287 16.31179 1.033833943 Mar 1 1.2295320 16.73571 0.434758468 Apr 1 -0.3297262 17.18666 -0.856933502 May 1 -0.4089856 17.63761 -0.728624284 Jun 1 1.3180134 18.09992 -1.217932700 Jul 1 -0.8149881 18.56223 -0.947240580 Aug 1 -0.4035568 19.02306 -1.319507650 Sep 1 -0.5521269 19.48390 -0.931773335 Oct 1 0.3888874 20.00539 -0.794279791 Nov 1 0.9099002 20.52688 1.863215256 Dec 1 0.5494702 20.98336 2.167166787 Jan 2 -1.2407906 21.43984 0.100949181 Feb 2 -0.6456287 21.70840 1.737231993 Mar 2 1.2295320 21.97695 1.093516022 Apr 2 -0.3297262 21.99080 -0.161078158 May 2 -0.4089856 22.00466 1.904328852 Jun 2 1.3180134 21.78549 -0.903503787 Jul 2 -0.8149881 21.56632 0.148664110 Aug 2 -0.4035568 21.26087 1.342686135 Sep 2 -0.5521269 20.95542 -0.903290454 Oct 2 0.3888874 20.64806 0.063050766 Nov 2 0.9099002 20.34071 0.749393489 Dec 2 0.5494702 20.07468 -1.424146451 Jan 3 -1.2407906 19.80865 -0.767855529 Feb 3 -0.6456287 19.59274 0.252889249 Mar 3 1.2295320 19.37683 -0.706364757 Apr 3 -0.3297262 19.22215 0.707575932 May 3 -0.4089856 19.06747 -0.558482190 Jun 3 1.3180134 18.94580 0.136187276 Jul 3 -0.8149881 18.82413 0.090857279 Aug 3 -0.4035568 18.70373 0.299822265 Sep 3 -0.5521269 18.58334 -0.431211364 Oct 3 0.3888874 18.49074 0.520371606 Nov 3 0.9099002 18.39814 -0.008043922 Dec 3 0.5494702 18.37170 -0.321172811 Jan 4 -1.2407906 18.34526 -0.204470838 Feb 4 -0.6456287 18.36043 -1.314804777 Mar 4 1.2295320 18.37561 -0.605137501 Apr 4 -0.3297262 18.36747 0.662252674 May 4 -0.4089856 18.35934 -0.850355962 Jun 4 1.3180134 18.29759 1.884393537 Jul 4 -0.8149881 18.23584 0.379143572 Aug 4 -0.4035568 18.12063 0.382928156 Sep 4 -0.5521269 18.00541 1.546714126 Oct 4 0.3888874 17.84810 0.663015646 Nov 4 0.9099002 17.69078 -1.800681331 Dec 4 0.5494702 17.51378 0.036750408 Jan 5 -1.2407906 17.33678 -0.395986991 Feb 5 -0.6456287 17.18241 -1.436783577 Mar 5 1.2295320 17.02805 0.042421053 Apr 5 -0.3297262 16.93482 -0.105089610 May 5 -0.4089856 16.84158 0.467400916 Jun 5 1.3180134 16.75049 0.331498377 Jul 5 -0.8149881 16.65939 0.555596374 Aug 5 -0.4035568 16.57500 -0.471447283 Sep 5 -0.5521269 16.49062 0.961510446 Oct 5 0.3888874 16.40671 -0.195593829 Nov 5 0.9099002 16.32280 -0.532696601 Dec 5 0.5494702 16.23557 -0.185036122 > 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/1oczm1260986031.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/22cn31260986031.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/3e2c21260986031.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/4w9tm1260986031.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/5oikx1260986031.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/6ckhw1260986031.tab") > try(system("convert tmp/1oczm1260986031.ps tmp/1oczm1260986031.png",intern=TRUE)) character(0) > try(system("convert tmp/22cn31260986031.ps tmp/22cn31260986031.png",intern=TRUE)) character(0) > try(system("convert tmp/3e2c21260986031.ps tmp/3e2c21260986031.png",intern=TRUE)) character(0) > try(system("convert tmp/4w9tm1260986031.ps tmp/4w9tm1260986031.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.982 0.632 1.170