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(101.3,106.3,94,102.8,102,105.1,92.4,81.4,105.8,120.3,100.7,88.8,94.3,99.9,103.4,103.3,98.8,104.2,91.2,74.7,108.5,114.5,96.9,89.6,97.1,100.3,122.6,115.4,109,129.1,102.8,96.2,127.7,128.9,126.5,119.8,113.2,114.1,134.1,130,121.8,132.1,105.3,103,117.1,126.3,138.1,119.5,138,135.5,178.6,162.2,176.9,204.9,132.2,142.5,164.3,174.9,175.4,143) > 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 -5.109465 99.20197 7.20749276 Feb 1 -3.728656 99.30242 10.72623977 Mar 1 10.532152 99.40286 -15.93501302 Apr 1 6.072658 99.48622 -2.75888125 May 1 4.373158 99.56958 -1.94274296 Jun 1 17.009781 99.57723 -11.48701423 Jul 1 -14.033586 99.58488 6.84870343 Aug 1 -20.270320 99.60066 2.06966063 Sep 1 3.832953 99.61644 2.35061141 Oct 1 10.678044 99.81586 9.80609957 Nov 1 3.763142 100.01528 -3.07842013 Dec 1 -13.119869 99.70646 2.21340943 Jan 2 -5.109465 99.39764 0.01182406 Feb 2 -3.728656 98.99830 4.63035850 Mar 2 10.532152 98.59895 -5.73110687 Apr 2 6.072658 98.37118 -1.14384208 May 2 4.373158 98.14341 -3.71657077 Jun 2 17.009781 98.21715 -11.02692948 Jul 2 -14.033586 98.29089 6.94270075 Aug 2 -20.270320 98.89526 -3.92494000 Sep 2 3.832953 99.49963 5.16741284 Oct 2 10.678044 100.60783 3.21412316 Nov 2 3.763142 101.71603 -8.57917439 Dec 2 -13.119869 103.04209 -0.32221662 Jan 3 -5.109465 104.36814 -2.15867378 Feb 3 -3.728656 105.87864 -1.84998202 Mar 3 10.532152 107.38914 4.67870993 Apr 3 6.072658 109.24042 0.08692429 May 3 4.373158 111.09170 -6.46485483 Jun 3 17.009781 113.01206 -0.92183668 Jul 3 -14.033586 114.93242 1.90117040 Aug 3 -20.270320 116.43574 0.03457712 Sep 3 3.832953 117.93907 5.92797742 Oct 3 10.678044 118.97403 -0.75207395 Nov 3 3.763142 120.00899 2.72786680 Dec 3 -13.119869 120.51373 12.40613963 Jan 4 -5.109465 121.01847 -2.70900248 Feb 4 -3.728656 120.93587 -3.10721846 Mar 4 10.532152 120.85328 2.71456575 Apr 4 6.072658 120.76134 3.16600191 May 4 4.373158 120.66940 -3.24255540 Jun 4 17.009781 121.36234 -6.27211581 Jul 4 -14.033586 122.05527 -2.72168730 Aug 4 -20.270320 124.16777 -0.89745154 Sep 4 3.832953 126.28027 -13.01322220 Oct 4 10.678044 129.91268 -14.29072774 Nov 4 3.763142 133.54510 0.79175886 Dec 4 -13.119869 138.02160 -5.40173499 Jan 5 -5.109465 142.49811 0.61135624 Feb 5 -3.728656 146.66187 -7.43321042 Mar 5 10.532152 150.82562 17.24222311 Apr 5 6.072658 153.32228 2.80505769 May 5 4.373158 155.81894 16.70789879 Jun 5 17.009781 158.15436 29.73585968 Jul 5 -14.033586 160.48978 -14.25619050 Aug 5 -20.270320 162.59608 0.17424064 Sep 5 3.832953 164.70238 -4.23533463 Oct 5 10.678044 166.51688 -2.29492296 Nov 5 3.763142 168.33138 3.30548084 Dec 5 -13.119869 169.93611 -13.81624084 > 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/161io1259772769.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/2qn2c1259772769.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/37v7q1259772769.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/4gpp41259772769.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/55a931259772769.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/66wty1259772769.tab") > system("convert tmp/161io1259772769.ps tmp/161io1259772769.png") > system("convert tmp/2qn2c1259772769.ps tmp/2qn2c1259772769.png") > system("convert tmp/37v7q1259772769.ps tmp/37v7q1259772769.png") > system("convert tmp/4gpp41259772769.ps tmp/4gpp41259772769.png") > > > proc.time() user system elapsed 0.932 0.604 1.277