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(1.4,1,-0.8,-2.9,-0.7,-0.7,1.5,3,3.2,3.1,3.9,1,1.3,0.8,1.2,2.9,3.9,4.5,4.5,3.3,2,1.5,1,2.1,3,4,5.1,4.5,4.2,3.3,2.7,1.8,1.4,0.5,-0.4,0.8,0.7,1.9,2,1.1,0.9,0.4,0.7,2.1,2.8,3.9,3.5,2,2,1.5,2.5,3.1,2.7,2.8,2.5,3,3.2,2.8,2.4,2,1.8,1.1,-1.5,-3.7) > 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.006242259 -0.31979404 1.726036299 Feb 1 0.005912555 -0.09246991 1.086557351 Mar 1 -0.298598181 0.13485423 -0.636256047 Apr 1 -0.855413904 0.35603444 -2.400620531 May 1 0.108328758 0.57721464 -1.385543400 Jun 1 -0.043761954 0.77570824 -1.431946290 Jul 1 0.264147032 0.97420185 0.261651122 Aug 1 0.549649087 1.17086990 1.279481011 Sep 1 0.455151509 1.36753796 1.377310534 Oct 1 0.294992176 1.65955532 1.145452508 Nov 1 0.014832487 1.95157268 1.933594837 Dec 1 -0.488996896 2.21552170 -0.726524805 Jan 2 -0.006242259 2.47947073 -1.173228468 Feb 2 0.005912555 2.57285700 -1.778769559 Mar 2 -0.298598181 2.66624328 -1.167645100 Apr 2 -0.855413904 2.63489699 1.120516912 May 2 0.108328758 2.60355070 1.188120539 Jun 2 -0.043761954 2.62024707 1.923514882 Jul 2 0.264147032 2.63694344 1.598909527 Aug 2 0.549649087 2.75539698 -0.005046071 Sep 2 0.455151509 2.87385053 -1.329002035 Oct 2 0.294992176 2.97498361 -1.769975787 Nov 2 0.014832487 3.07611670 -2.090949184 Dec 2 -0.488996896 3.10557916 -0.516582267 Jan 3 -0.006242259 3.13504163 -0.128799370 Feb 3 0.005912555 3.11697373 0.877113710 Mar 3 -0.298598181 3.09890584 2.299692340 Apr 3 -0.855413904 3.00094753 2.354466371 May 3 0.108328758 2.90298923 1.188682016 Jun 3 -0.043761954 2.68447137 0.659290587 Jul 3 0.264147032 2.46595351 -0.030100541 Aug 3 0.549649087 2.18916666 -0.938815747 Sep 3 0.455151509 1.91237981 -0.967531321 Oct 3 0.294992176 1.66683209 -1.461824267 Nov 3 0.014832487 1.42128437 -1.836116857 Dec 3 -0.488996896 1.27745559 0.011541309 Jan 4 -0.006242259 1.13362680 -0.427384545 Feb 4 0.005912555 1.15090128 0.743186160 Mar 4 -0.298598181 1.16817576 1.130422417 Apr 4 -0.855413904 1.33058739 0.624826513 May 4 0.108328758 1.49299902 -0.701327777 Jun 4 -0.043761954 1.64549789 -1.201735937 Jul 4 0.264147032 1.79799676 -1.362143796 Aug 4 0.549649087 1.89318306 -0.342832148 Sep 4 0.455151509 1.98836936 0.356479133 Oct 4 0.294992176 2.12000190 1.485005921 Nov 4 0.014832487 2.25163445 1.233533065 Dec 4 -0.488996896 2.39821083 0.090786063 Jan 5 -0.006242259 2.54478722 -0.538544959 Feb 5 0.005912555 2.60091161 -1.106824166 Mar 5 -0.298598181 2.65703600 0.141562178 Apr 5 -0.855413904 2.63733656 1.318077340 May 5 0.108328758 2.61763712 -0.025965883 Jun 5 -0.043761954 2.58396157 0.259800382 Jul 5 0.264147032 2.55028602 -0.314433051 Aug 5 0.549649087 2.29784668 0.152504230 Sep 5 0.455151509 2.04540735 0.699441144 Oct 5 0.294992176 1.72427445 0.780733374 Nov 5 0.014832487 1.40314155 0.982025961 Dec 5 -0.488996896 1.07008661 1.418910282 Jan 6 -0.006242259 0.73703168 1.069210583 Feb 6 0.005912555 0.38425390 0.709833542 Mar 6 -0.298598181 0.03147613 -1.232877948 Apr 6 -0.855413904 -0.34566854 -2.498917559 > m$win s t l 641 19 13 > m$deg s t l 0 1 1 > m$jump s t l 65 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/109r41259961556.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/2vo0w1259961556.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/3bjem1259961556.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/47kfd1259961556.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/5rkhq1259961556.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/651qw1259961556.tab") > system("convert tmp/109r41259961556.ps tmp/109r41259961556.png") > system("convert tmp/2vo0w1259961556.ps tmp/2vo0w1259961556.png") > system("convert tmp/3bjem1259961556.ps tmp/3bjem1259961556.png") > system("convert tmp/47kfd1259961556.ps tmp/47kfd1259961556.png") > > > proc.time() user system elapsed 0.965 0.623 1.148