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(20366,22782,19169,13807,29743,25591,29096,26482,22405,27044,17970,18730,19684,19785,18479,10698,31956,29506,34506,27165,26736,23691,18157,17328,18205,20995,17382,9367,31124,26551,30651,25859,25100,25778,20418,18688,20424,24776,19814,12738,31566,30111,30019,31934,25826,26835,20205,17789,20520,22518,15572,11509,25447,24090,27786,26195,20516,22759,19028,16971,20036) > 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 -2808.362 23476.65 -302.285614 Feb 1 -757.585 23331.07 208.515541 Mar 1 -4792.049 23185.49 775.557643 Apr 1 -11227.753 23058.68 1976.071732 May 1 7139.347 22931.87 -328.218645 Jun 1 4347.983 22818.32 -1575.304940 Jul 1 7595.819 22704.77 -1204.591326 Aug 1 4745.290 22581.99 -845.276534 Sep 1 1368.964 22459.20 -1423.163989 Oct 1 2536.226 22409.72 2098.051717 Nov 1 -3467.109 22360.24 -923.134712 Dec 1 -4680.770 22561.71 849.061213 Jan 2 -2808.362 22763.17 -270.811114 Feb 2 -757.585 22988.48 -2445.893978 Mar 2 -4792.049 23213.78 57.264107 Apr 2 -11227.753 23288.00 -1362.250059 May 2 7139.347 23362.22 1454.431309 Jun 2 4347.983 23328.28 1829.739323 Jul 2 7595.819 23294.33 3615.847245 Aug 2 4745.290 23199.64 -779.930262 Sep 2 1368.964 23104.95 2262.089983 Oct 2 2536.226 22929.71 -1774.932141 Nov 2 -3467.109 22754.47 -1130.356402 Dec 2 -4680.770 22546.38 -537.611745 Jan 3 -2808.362 22338.30 -1324.935340 Feb 3 -757.585 22237.13 -484.545955 Mar 3 -4792.049 22135.96 38.084378 Apr 3 -11227.753 22210.35 -1615.597585 May 3 7139.347 22284.74 1699.915988 Jun 3 4347.983 22463.77 -260.748166 Jul 3 7595.819 22642.79 412.387589 Aug 3 4745.290 22861.37 -1747.660259 Sep 3 1368.964 23079.95 651.089646 Oct 3 2536.226 23290.41 -48.638112 Nov 3 -3467.109 23500.88 384.231993 Dec 3 -4680.770 23688.93 -320.164415 Jan 4 -2808.362 23876.99 -644.629076 Feb 4 -757.585 24059.77 1473.816805 Mar 4 -4792.049 24242.55 363.503634 Apr 4 -11227.753 24336.46 -370.706367 May 4 7139.347 24430.37 -3.720834 Jun 4 4347.983 24400.36 1362.660943 Jul 4 7595.819 24370.34 -1947.157371 Aug 4 4745.290 24208.78 2979.929218 Sep 4 1368.964 24047.22 409.813560 Oct 4 2536.226 23745.61 553.162808 Nov 4 -3467.109 23444.00 228.109920 Dec 4 -4680.770 23035.20 -565.426576 Jan 5 -2808.362 22626.39 701.968675 Feb 5 -757.585 22205.99 1069.594289 Mar 5 -4792.049 21785.59 -1421.539148 Apr 5 -11227.753 21546.94 1189.813713 May 5 7139.347 21308.29 -3000.637892 Jun 5 4347.983 21245.79 -1503.771415 Jul 5 7595.819 21183.29 -993.105031 Aug 5 4745.290 21136.63 313.079219 Sep 5 1368.964 21089.98 -1942.938777 Oct 5 2536.226 21070.56 -847.783842 Nov 5 -3467.109 21051.14 1443.968958 Dec 5 -4680.770 21070.42 581.347015 Jan 6 -2808.362 21089.71 1754.656820 > m$win s t l 611 19 13 > m$deg s t l 0 1 1 > m$jump s t l 62 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1hcv81259929443.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/2i5xm1259929443.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/30jd01259929443.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/4a2a51259929443.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/5s21e1259929443.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/66qtj1259929443.tab") > system("convert tmp/1hcv81259929443.ps tmp/1hcv81259929443.png") > system("convert tmp/2i5xm1259929443.ps tmp/2i5xm1259929443.png") > system("convert tmp/30jd01259929443.ps tmp/30jd01259929443.png") > system("convert tmp/4a2a51259929443.ps tmp/4a2a51259929443.png") > > > proc.time() user system elapsed 0.938 0.612 1.152