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(12008,9169,8788,8417,8247,8197,8236,8253,7733,8366,8626,8863,10102,8463,9114,8563,8872,8301,8301,8278,7736,7973,8268,9476,11100,8962,9173,8738,8459,8078,8411,8291,7810,8616,8312,9692,9911,8915,9452,9112,8472,8230,8384,8625,8221,8649,8625,10443,10357,8586,8892,8329,8101,7922,8120,7838,7735,8406,8209,9451,10041,9411,10405,8467,8464,8102,7627,7513,7510,8291,8064,9383) > 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 1824.1809 9101.986 1081.832764 Feb 1 170.5233 9034.899 -36.422055 Mar 1 572.0323 8967.811 -751.843514 Apr 1 -114.6699 8902.165 -370.495097 May 1 -270.2059 8836.519 -319.312816 Jun 1 -558.2061 8770.425 -15.219296 Jul 1 -507.2060 8704.332 38.873933 Aug 1 -546.3469 8646.830 152.516568 Sep 1 -880.8212 8589.329 24.492653 Oct 1 -282.0528 8581.831 66.221915 Nov 1 -308.7844 8574.333 360.451184 Dec 1 901.5568 8585.994 -624.550316 Jan 2 1824.1809 8597.654 -319.834654 Feb 2 170.5233 8605.860 -313.383577 Mar 2 572.0323 8614.067 -72.099139 Apr 2 -114.6699 8620.843 56.827029 May 2 -270.2059 8627.619 514.587061 Jun 2 -558.2061 8652.530 206.676130 Jul 2 -507.2060 8677.441 130.764909 Aug 2 -546.3469 8702.517 121.830241 Sep 2 -880.8212 8727.592 -110.770977 Oct 2 -282.0528 8728.936 -473.883545 Nov 2 -308.7844 8730.281 -153.496105 Dec 2 901.5568 8726.112 -151.668896 Jan 3 1824.1809 8721.944 553.875474 Feb 3 170.5233 8733.725 57.751343 Mar 3 572.0323 8745.507 -144.539427 Apr 3 -114.6699 8759.584 93.086212 May 3 -270.2059 8773.660 -44.454285 Jun 3 -558.2061 8764.129 -127.922491 Jul 3 -507.2060 8754.597 163.609013 Aug 3 -546.3469 8741.136 96.211269 Sep 3 -880.8212 8727.674 -36.853024 Oct 3 -282.0528 8732.894 165.159142 Nov 3 -308.7844 8738.113 -117.328684 Dec 3 901.5568 8749.479 40.963960 Jan 4 1824.1809 8760.845 -674.026234 Feb 4 170.5233 8779.635 -35.158551 Mar 4 572.0323 8798.425 81.542492 Apr 4 -114.6699 8830.836 395.833641 May 4 -270.2059 8863.247 -121.041346 Jun 4 -558.2061 8894.910 -106.704293 Jul 4 -507.2060 8926.574 -35.367529 Aug 4 -546.3469 8921.760 249.586504 Sep 4 -880.8212 8916.947 184.873988 Oct 4 -282.0528 8875.938 55.114910 Nov 4 -308.7844 8834.929 98.855840 Dec 4 901.5568 8788.026 753.417302 Jan 5 1824.1809 8741.123 -208.304073 Feb 5 170.5233 8692.228 -276.751501 Mar 5 572.0323 8643.333 -323.365569 Apr 5 -114.6699 8601.180 -157.509979 May 5 -270.2059 8559.026 -187.820525 Jun 5 -558.2061 8538.066 -57.860201 Jul 5 -507.2060 8517.106 110.099832 Aug 5 -546.3469 8548.854 -164.506991 Sep 5 -880.8212 8580.602 35.219636 Oct 5 -282.0528 8628.236 59.816873 Nov 5 -308.7844 8675.870 -158.085882 Dec 5 901.5568 8692.804 -143.360572 Jan 6 1824.1809 8709.737 -492.918101 Feb 6 170.5233 8695.111 545.365567 Mar 6 572.0323 8680.485 1152.482595 Apr 6 -114.6699 8646.141 -64.471353 May 6 -270.2059 8611.797 122.408562 Jun 6 -558.2061 8578.990 81.216378 Jul 6 -507.2060 8546.182 -411.976097 Aug 6 -546.3469 8506.374 -447.027341 Sep 6 -880.8212 8466.566 -75.745134 Oct 6 -282.0528 8422.369 150.683898 Nov 6 -308.7844 8378.172 -5.387061 Dec 6 901.5568 8332.994 148.448721 > m$win s t l 721 19 13 > m$deg s t l 0 1 1 > m$jump s t l 73 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1b0f21259944874.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/212cg1259944874.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/3sqo31259944874.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/4sgu11259944874.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/5mci31259944874.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/6nh971259944874.tab") > > system("convert tmp/1b0f21259944874.ps tmp/1b0f21259944874.png") > system("convert tmp/212cg1259944874.ps tmp/212cg1259944874.png") > system("convert tmp/3sqo31259944874.ps tmp/3sqo31259944874.png") > system("convert tmp/4sgu11259944874.ps tmp/4sgu11259944874.png") > > > proc.time() user system elapsed 1.046 0.643 2.489