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(8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7,7.1,7.2,7.1,6.9,7,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,8,8.1,8) > 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.03711396 7.838324 0.298790414 Feb 1 -0.22198945 7.799911 0.122078793 Mar 1 -0.31767484 7.761498 0.056177077 Apr 1 -0.10188884 7.729438 -0.027548732 May 1 0.23389702 7.697377 -0.131274391 Jun 1 0.34786105 7.670472 -0.218333042 Jul 1 0.26182509 7.643567 -0.105391705 Aug 1 0.12463640 7.620841 -0.245477828 Sep 1 -0.09255246 7.598116 -0.005563789 Oct 1 -0.29612970 7.607541 -0.211410943 Nov 1 0.08029305 7.616965 -0.197258098 Dec 1 0.01883712 7.657080 -0.175916905 Jan 2 -0.03711396 7.697195 -0.060080556 Feb 2 -0.22198945 7.739971 0.182018631 Mar 2 -0.31767484 7.782747 0.234927723 Apr 2 -0.10188884 7.791127 0.210761657 May 2 0.23389702 7.799507 0.066595741 Jun 2 0.34786105 7.747529 0.104609473 Jul 2 0.26182509 7.695552 0.242623192 Aug 2 0.12463640 7.612902 0.462461580 Sep 2 -0.09255246 7.530252 0.462300130 Oct 2 -0.29612970 7.444839 0.151290361 Nov 2 0.08029305 7.359426 -0.539719409 Dec 2 0.01883712 7.266809 -0.685646151 Jan 3 -0.03711396 7.174192 -0.437077738 Feb 3 -0.22198945 7.089598 0.032391847 Mar 3 -0.31767484 7.005004 0.312671336 Apr 3 -0.10188884 6.955712 0.246176645 May 3 0.23389702 6.906421 0.059682103 Jun 3 0.34786105 6.875660 -0.123521524 Jul 3 0.26182509 6.844900 -0.206725164 Aug 3 0.12463640 6.798863 0.076500356 Sep 3 -0.09255246 6.752826 0.139726037 Oct 3 -0.29612970 6.707252 -0.011122186 Nov 3 0.08029305 6.661677 -0.041970409 Dec 3 0.01883712 6.621702 -0.040539385 Jan 4 -0.03711396 6.581727 -0.144613205 Feb 4 -0.22198945 6.530718 -0.008728739 Mar 4 -0.31767484 6.479709 0.037965631 Apr 4 -0.10188884 6.453416 0.148472380 May 4 0.23389702 6.427124 0.138979278 Jun 4 0.34786105 6.443987 0.008151780 Jul 4 0.26182509 6.460851 -0.322675730 Aug 4 0.12463640 6.473914 -0.498550879 Sep 4 -0.09255246 6.486978 -0.594425865 Oct 4 -0.29612970 6.499248 -0.103118559 Nov 4 0.08029305 6.511518 0.608188746 Dec 4 0.01883712 6.575460 0.705702652 Jan 5 -0.03711396 6.639402 0.297711712 Feb 5 -0.22198945 6.744556 -0.422566143 Mar 5 -0.31767484 6.849709 -0.732034094 Apr 5 -0.10188884 6.963396 -0.661507626 May 5 0.23389702 7.077084 -0.210981009 Jun 5 0.34786105 7.200566 0.151573329 Jul 5 0.26182509 7.324047 0.314127654 Aug 5 0.12463640 7.454370 0.120993181 Sep 5 -0.09255246 7.584694 -0.092141130 Oct 5 -0.29612970 7.721117 0.075012584 Nov 5 0.08029305 7.857541 0.062166298 Dec 5 0.01883712 7.997670 0.083492383 Jan 6 -0.03711396 8.137800 -0.100686378 > m$win s t l 611 19 13 > m$deg s t l 0 1 1 > m$jump s t l 62 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1fqfz1259864120.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/2hbdw1259864120.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/392rr1259864120.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/4fnq01259864120.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/5hoqb1259864120.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/6xl8t1259864120.tab") > > system("convert tmp/1fqfz1259864120.ps tmp/1fqfz1259864120.png") > system("convert tmp/2hbdw1259864120.ps tmp/2hbdw1259864120.png") > system("convert tmp/392rr1259864120.ps tmp/392rr1259864120.png") > system("convert tmp/4fnq01259864120.ps tmp/4fnq01259864120.png") > > > proc.time() user system elapsed 0.951 0.600 1.144