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(12.6,15.7,13.2,20.3,12.8,8,0.9,3.6,14.1,21.7,24.5,18.9,13.9,11,5.8,15.5,22.4,31.7,30.3,31.4,20.2,19.7,10.8,13.2,15.1,15.6,15.5,12.7,10.9,10,9.1,10.3,16.9,22,27.6,28.9,31,32.9,38.1,28.8,29,21.8,28.8,25.6,28.2,20.2,17.9,16.3,13.2,8.1,4.5,-0.1,0,2.3,2.8,2.9,0.1,3.5,8.6,13.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.40185208 13.556612 -1.3584636 Feb 1 0.01518888 13.491847 2.1929640 Mar 1 -1.11147327 13.427083 0.8843905 Apr 1 -1.06414578 13.426185 7.9379608 May 1 -1.45681456 13.425287 0.8315275 Jun 1 -1.59318246 13.454719 -3.8615362 Jul 1 -1.84954883 13.484150 -10.7346014 Aug 1 -1.26297234 13.427684 -8.5647119 Sep 1 0.08360343 13.371218 0.6451783 Oct 1 1.91243490 13.537301 6.2502637 Nov 1 2.68126696 13.703384 8.1153486 Dec 1 3.24379148 15.016778 0.6394308 Jan 2 0.40185208 16.330171 -2.8320230 Feb 2 0.01518888 17.792535 -6.8077237 Mar 2 -1.11147327 19.254899 -12.3434255 Apr 2 -1.06414578 19.729222 -3.1650764 May 2 -1.45681456 20.203546 3.6532690 Jun 2 -1.59318246 20.176208 13.1169747 Jul 2 -1.84954883 20.148870 12.0006789 Aug 2 -1.26297234 20.062142 12.6008302 Sep 2 0.08360343 19.975414 0.1409823 Oct 2 1.91243490 19.280249 -1.4926837 Nov 2 2.68126696 18.585083 -10.4663503 Dec 2 3.24379148 17.204558 -7.2483491 Jan 3 0.40185208 15.824032 -1.1258840 Feb 3 0.01518888 14.855490 0.7293211 Mar 3 -1.11147327 13.886948 2.7245251 Apr 3 -1.06414578 14.088300 -0.3241547 May 3 -1.45681456 14.289653 -1.9328382 Jun 3 -1.59318246 15.346361 -3.7531788 Jul 3 -1.84954883 16.403070 -5.4535209 Aug 3 -1.26297234 17.938991 -6.3760190 Sep 3 0.08360343 19.474913 -2.6585163 Oct 3 1.91243490 21.229344 -1.1417786 Nov 3 2.68126696 22.983775 1.9349585 Dec 3 3.24379148 24.578189 1.0780192 Jan 4 0.40185208 26.172604 4.4255439 Feb 4 0.01518888 27.211916 5.6728949 Mar 4 -1.11147327 28.251228 10.9602449 Apr 4 -1.06414578 28.224922 1.6392238 May 4 -1.45681456 28.198616 2.2581989 Jun 4 -1.59318246 27.001338 -3.6081559 Jul 4 -1.84954883 25.804061 4.8454878 Aug 4 -1.26297234 23.747683 3.1152896 Sep 4 0.08360343 21.691304 6.4250922 Oct 4 1.91243490 19.289870 -1.0023051 Nov 4 2.68126696 16.888436 -1.6697029 Dec 4 3.24379148 14.605215 -1.5490060 Jan 5 0.40185208 12.321993 0.4761548 Feb 5 0.01518888 10.308497 -2.2236854 Mar 5 -1.11147327 8.295000 -2.6835267 Apr 5 -1.06414578 7.397135 -6.4329896 May 5 -1.45681456 6.499271 -5.0424562 Jun 5 -1.59318246 5.811455 -1.9182730 Jul 5 -1.84954883 5.123640 -0.4740913 Aug 5 -1.26297234 4.537676 -0.3747035 Sep 5 0.08360343 3.951712 -3.9353150 Oct 5 1.91243490 3.476692 -1.8891273 Nov 5 2.68126696 3.001673 2.9170598 Dec 5 3.24379148 2.623240 7.9329683 > 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/1qrrg1259943837.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/2bz4d1259943837.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/3gp3s1259943837.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/4p8c11259943837.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/5h4oi1259943837.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/6rq0x1259943837.tab") > system("convert tmp/1qrrg1259943837.ps tmp/1qrrg1259943837.png") > system("convert tmp/2bz4d1259943837.ps tmp/2bz4d1259943837.png") > system("convert tmp/3gp3s1259943837.ps tmp/3gp3s1259943837.png") > system("convert tmp/4p8c11259943837.ps tmp/4p8c11259943837.png") > > > proc.time() user system elapsed 0.963 0.597 1.124