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(107.11,107.57,107.81,108.75,109.43,109.62,109.54,109.53,109.84,109.67,109.79,109.56,110.22,110.40,110.69,110.72,110.89,110.58,110.94,110.91,111.22,111.09,111.00,111.06,111.55,112.32,112.64,112.36,112.04,112.37,112.59,112.89,113.22,112.85,113.06,112.99,113.32,113.74,113.91,114.52,114.96,114.91,115.30,115.44,115.52,116.08,115.94,115.56,115.88,116.66,117.41,117.68,117.85,118.21,118.92,119.03,119.17,118.95,118.92,118.90) > 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.52935963 107.8166 -0.1772246280 Feb 1 -0.20628971 108.0419 -0.2655762438 Mar 1 -0.05121985 108.2671 -0.4059277890 Apr 1 0.10162428 108.4876 0.1607558838 May 1 0.16846850 108.7081 0.5534394768 Jun 1 0.12869769 108.9281 0.5631701878 Jul 1 0.30492698 109.1482 0.0869008033 Aug 1 0.24913309 109.3690 -0.0881454377 Sep 1 0.32533915 109.5899 -0.0751916317 Oct 1 0.06646758 109.7725 -0.1689621802 Nov 1 -0.11240405 109.9551 -0.0527326686 Dec 1 -0.44538403 110.0826 -0.0772151278 Jan 2 -0.52935963 110.2101 0.5392980353 Feb 2 -0.20628971 110.3233 0.2829641443 Mar 2 -0.05121985 110.4366 0.3046303239 Apr 2 0.10162428 110.5372 0.0811492961 May 2 0.16846850 110.6379 0.0836681886 Jun 2 0.12869769 110.7419 -0.2906043590 Jul 2 0.30492698 110.8460 -0.2108770020 Aug 2 0.24913309 110.9806 -0.3197305095 Sep 2 0.32533915 111.1152 -0.2205839699 Oct 2 0.06646758 111.2695 -0.2459643821 Nov 2 -0.11240405 111.4237 -0.3113447342 Dec 2 -0.44538403 111.5773 -0.0719493910 Jan 3 -0.52935963 111.7309 0.3484415745 Feb 3 -0.20628971 111.8842 0.6421194690 Mar 3 -0.05121985 112.0374 0.6537974342 Apr 3 0.10162428 112.1842 0.0742008899 May 3 0.16846850 112.3309 -0.4593957340 Jun 3 0.12869769 112.4670 -0.2257269085 Jul 3 0.30492698 112.6031 -0.3180581783 Aug 3 0.24913309 112.7441 -0.1032310194 Sep 3 0.32533915 112.8851 0.0095961866 Oct 3 0.06646758 113.0686 -0.2850964578 Nov 3 -0.11240405 113.2522 -0.0797890421 Dec 3 -0.44538403 113.4704 -0.0349790592 Jan 4 -0.52935963 113.6885 0.1608265458 Feb 4 -0.20628971 113.9109 0.0354046776 Mar 4 -0.05121985 114.1332 -0.1720171201 Apr 4 0.10162428 114.3605 0.0578610161 May 4 0.16846850 114.5878 0.2037390725 Jun 4 0.12869769 114.8167 -0.0353585820 Jul 4 0.30492698 115.0455 -0.0504563319 Aug 4 0.24913309 115.2875 -0.0966443705 Sep 4 0.32533915 115.5295 -0.3348323621 Oct 4 0.06646758 115.7909 0.2226523464 Nov 4 -0.11240405 116.0523 0.0001371149 Dec 4 -0.44538403 116.3328 -0.3274321098 Jan 5 -0.52935963 116.6134 -0.2040057124 Feb 5 -0.20628971 116.9053 -0.0389713656 Mar 5 -0.05121985 117.1972 0.2640630518 Apr 5 0.10162428 117.4630 0.1153628198 May 5 0.16846850 117.7289 -0.0473374919 Jun 5 0.12869769 117.9894 0.0918643569 Jul 5 0.30492698 118.2500 0.3650661103 Aug 5 0.24913309 118.5097 0.2712094868 Sep 5 0.32533915 118.7693 0.0753529104 Oct 5 0.06646758 119.0252 -0.1416484470 Nov 5 -0.11240405 119.2811 -0.2486497443 Dec 5 -0.44538403 119.5327 -0.1873055639 > 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/13cph1259954116.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/2xjen1259954116.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/3kjd51259954116.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/4jqbs1259954116.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/5r5wu1259954116.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/6j3p51259954116.tab") > system("convert tmp/13cph1259954116.ps tmp/13cph1259954116.png") > system("convert tmp/2xjen1259954116.ps tmp/2xjen1259954116.png") > system("convert tmp/3kjd51259954116.ps tmp/3kjd51259954116.png") > system("convert tmp/4jqbs1259954116.ps tmp/4jqbs1259954116.png") > > > proc.time() user system elapsed 0.975 0.624 1.146