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(95.5,76.7,79.4,55.2,60,64.8,82.3,210.5,106,80.8,97.3,189.5,90,69.3,87.3,57.4,56.2,61.6,77.7,177.2,97.6,81.6,96.8,191.3,106,75.1,72,63.5,57.4,62.3,79.4,178.1,109.3,85.2,102.7,193.7,108.4,73.4,85.9,58.5,58.6,62.7,77.5,180.5,102.2,82.6,97.8,197.8,93.8,72.4,77.7,58.7,53.1,64.3,76.4,188.4,105.5,79.8,96.1,202.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 0.6352642 99.29973 -4.43499511 Feb 1 -24.6313682 99.44490 1.88647134 Mar 1 -17.4579946 99.59006 -2.73206814 Apr 1 -39.2178694 99.61949 -5.20161591 May 1 -40.7777473 99.64891 1.12883942 Jun 1 -34.7552437 99.58950 -0.03425787 Jul 1 -19.2927376 99.53010 2.06264241 Aug 1 88.9194804 99.49223 22.08829248 Sep 1 6.0317192 99.45436 0.51392167 Oct 1 -16.1448987 99.29307 -2.34816968 Nov 1 -0.0615190 99.13178 -1.77025864 Dec 1 96.7529148 98.49927 -5.75218204 Jan 2 0.6352642 97.86676 -8.50202102 Feb 2 -24.6313682 96.99346 -3.06209515 Mar 2 -17.4579946 96.12017 8.63782479 Apr 2 -39.2178694 95.79279 0.82507864 May 2 -40.7777473 95.46541 1.51233561 Jun 2 -34.7552437 95.66605 0.68919190 Jul 2 -19.2927376 95.86669 1.12604576 Aug 2 88.9194804 96.03422 -7.75369825 Sep 2 6.0317192 96.20174 -4.63346315 Oct 2 -16.1448987 96.28446 1.46043765 Nov 2 -0.0615190 96.36718 0.49434082 Dec 2 96.7529148 96.60299 -2.05590923 Jan 3 0.6352642 96.83881 8.52592513 Feb 3 -24.6313682 97.15528 2.57608694 Mar 3 -17.4579946 97.47175 -8.01375719 Apr 3 -39.2178694 97.76931 4.94855511 May 3 -40.7777473 98.06688 0.11087052 Jun 3 -34.7552437 98.34673 -1.29148600 Jul 3 -19.2927376 98.62658 0.06615504 Aug 3 88.9194804 98.93229 -9.75176584 Sep 3 6.0317192 99.23799 4.03029240 Oct 3 -16.1448987 99.50906 1.83583828 Nov 3 -0.0615190 99.78013 2.98138654 Dec 3 96.7529148 99.83463 -2.88754709 Jan 4 0.6352642 99.88913 7.87560369 Feb 4 -24.6313682 99.68505 -1.65368205 Mar 4 -17.4579946 99.48097 3.87702628 Apr 4 -39.2178694 99.09015 -1.37228009 May 4 -40.7777473 98.69933 0.67841665 Jun 4 -34.7552437 98.30225 -0.84700661 Jul 4 -19.2927376 97.90517 -1.11243231 Aug 4 88.9194804 97.52683 -5.94631221 Sep 4 6.0317192 97.14849 -0.98021299 Oct 4 -16.1448987 96.92130 1.82359642 Nov 4 -0.0615190 96.69411 1.16740820 Dec 4 96.7529148 96.69231 4.35477731 Jan 5 0.6352642 96.69050 -3.52576918 Feb 5 -24.6313682 96.81971 0.21166005 Mar 5 -17.4579946 96.94891 -1.79091667 Apr 5 -39.2178694 97.14565 0.77221576 May 5 -40.7777473 97.34240 -3.46464871 Jun 5 -34.7552437 97.63564 1.41960188 Jul 5 -19.2927376 97.92889 -2.23614996 Aug 5 88.9194804 98.25394 1.22658351 Sep 5 6.0317192 98.57898 0.88929609 Oct 5 -16.1448987 98.92968 -2.98478591 Nov 5 -0.0615190 99.28038 -3.11886552 Dec 5 96.7529148 99.65320 6.09388767 > 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/1c83i1259948439.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/2egtd1259948439.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/3gtrp1259948439.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/4byo61259948439.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/5e8ul1259948439.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/6n35w1259948439.tab") > system("convert tmp/1c83i1259948439.ps tmp/1c83i1259948439.png") > system("convert tmp/2egtd1259948439.ps tmp/2egtd1259948439.png") > system("convert tmp/3gtrp1259948439.ps tmp/3gtrp1259948439.png") > system("convert tmp/4byo61259948439.ps tmp/4byo61259948439.png") > > > proc.time() user system elapsed 0.977 0.619 1.154