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(153.4,145,137.7,148.3,152.2,169.4,168.6,161.1,174.1,179,190.6,190,181.6,174.8,180.5,196.8,193.8,197,216.3,221.4,217.9,229.7,227.4,204.2,196.6,198.8,207.5,190.7,201.6,210.5,223.5,223.8,231.2,244,234.7,250.2,265.7,287.6,283.3,295.4,312.3,333.8,347.7,383.2,407.1,413.6,362.7,321.9,239.4,191,159.7,163.4,157.6,166.2,176.7,198.3,226.2,216.2,235.9,226.9) > 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 -13.0543606 164.3060 2.1483294 Feb 1 -21.5224563 164.5855 1.9369655 Mar 1 -27.7905570 164.8650 0.6256065 Apr 1 -24.3585722 165.4795 7.1790784 May 1 -21.5265778 166.0940 7.6325408 Jun 1 -10.1322363 167.1575 12.3747635 Jul 1 0.5621115 168.2209 -0.1830201 Aug 1 12.3832245 169.6119 -20.8950873 Sep 1 26.9443298 171.0028 -23.8471468 Oct 1 33.2346057 173.5560 -27.7906122 Nov 1 28.0848569 176.1092 -13.5940531 Dec 1 17.1756874 180.5784 -7.7541096 Jan 2 -13.0543606 185.0476 9.6067124 Feb 2 -21.5224563 189.8674 6.4550863 Mar 2 -27.7905570 194.6871 13.6034651 Apr 2 -24.3585722 198.2417 22.9169085 May 2 -21.5265778 201.7962 13.5303422 Jun 2 -10.1322363 203.3160 3.8162446 Jul 2 0.5621115 204.8357 10.9021406 Aug 2 12.3832245 205.5701 3.4466313 Sep 2 26.9443298 206.3045 -15.3488703 Oct 2 33.2346057 207.0623 -10.5968967 Nov 2 28.0848569 207.8200 -8.5048985 Dec 2 17.1756874 208.9529 -21.9285405 Jan 3 -13.0543606 210.0857 -0.4313041 Feb 3 -21.5224563 211.3948 8.9276705 Mar 3 -27.7905570 212.7039 22.5866499 Apr 3 -24.3585722 214.0779 0.9806428 May 3 -21.5265778 215.4520 7.6746262 Jun 3 -10.1322363 218.0262 2.6060681 Jul 3 0.5621115 220.6004 2.3375036 Aug 3 12.3832245 225.9703 -14.5535583 Sep 3 26.9443298 231.3403 -27.0846123 Oct 3 33.2346057 239.8118 -29.0463675 Nov 3 28.0848569 248.2832 -41.6680981 Dec 3 17.1756874 259.5220 -26.4977195 Jan 4 -13.0543606 270.7608 7.9935376 Feb 4 -21.5224563 284.3288 24.7936338 Mar 4 -27.7905570 297.8968 13.1937349 Apr 4 -24.3585722 310.4944 9.2642098 May 4 -21.5265778 323.0919 10.7346752 Jun 4 -10.1322363 328.4128 15.5194301 Jul 4 0.5621115 333.7337 13.4041786 Aug 4 12.3832245 328.8655 41.9512546 Sep 4 26.9443298 323.9973 56.1583384 Oct 4 33.2346057 311.9420 68.4233869 Nov 4 28.0848569 299.8867 34.7284600 Dec 4 17.1756874 283.9247 20.7996244 Jan 5 -13.0543606 267.9627 -15.5083327 Feb 5 -21.5224563 251.2060 -38.6835099 Mar 5 -27.7905570 234.4492 -46.9586822 Apr 5 -24.3585722 225.5688 -37.8102134 May 5 -21.5265778 216.6883 -37.5617541 Jun 5 -10.1322363 208.9414 -32.6091210 Jul 5 0.5621115 201.1944 -25.0564942 Aug 5 12.3832245 194.4204 -8.5036479 Sep 5 26.9443298 187.6465 11.6092061 Oct 5 33.2346057 182.0862 0.8791686 Nov 5 28.0848569 176.5260 31.2891557 Dec 5 17.1756874 171.8909 37.8333790 > 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/1jcv51260375149.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/251gg1260375149.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/3kg9j1260375149.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/40c5k1260375149.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/5zatb1260375149.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/6sodp1260375149.tab") > system("convert tmp/1jcv51260375149.ps tmp/1jcv51260375149.png") > system("convert tmp/251gg1260375149.ps tmp/251gg1260375149.png") > system("convert tmp/3kg9j1260375149.ps tmp/3kg9j1260375149.png") > system("convert tmp/40c5k1260375149.ps tmp/40c5k1260375149.png") > > > proc.time() user system elapsed 0.944 0.597 1.139