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(58608,46865,51378,46235,47206,45382,41227,33795,31295,42625,33625,21538,56421,53152,53536,52408,41454,38271,35306,26414,31917,38030,27534,18387,50556,43901,48572,43899,37532,40357,35489,29027,34485,42598,30306,26451,47460,50104,61465,53726,39477,43895,31481,29896,33842,39120,33702,25094,51442,45594,52518,48564,41745,49585,32747,33379,35645,37034,35681,20972) > 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 12659.1390 41597.81 4351.0558 Feb 1 7700.9285 41654.16 -2490.0893 Mar 1 13287.5150 41710.52 -3620.0313 Apr 1 8768.6005 41746.93 -4280.5283 May 1 1293.4826 41783.34 4129.1782 Jun 1 3329.3779 41816.65 235.9752 Jul 1 -4897.9240 41849.95 4274.9693 Aug 1 -9623.8548 41936.79 1482.0634 Sep 1 -6667.3817 42023.63 -4061.2465 Oct 1 -239.4873 42079.41 785.0819 Nov 1 -7967.9957 42135.18 -542.1869 Dec 1 -17642.3980 41818.77 -2638.3686 Jan 2 12659.1390 41502.35 2259.5103 Feb 2 7700.9285 41119.75 4331.3172 Mar 2 13287.5150 40737.16 -488.6729 Apr 2 8768.6005 40347.43 3291.9721 May 2 1293.4826 39957.70 202.8205 Jun 2 3329.3779 39457.33 -4515.7112 Jul 2 -4897.9240 38956.97 1246.9543 Aug 2 -9623.8548 38406.08 -2368.2257 Sep 2 -6667.3817 37855.19 729.1903 Oct 2 -239.4873 37452.71 816.7776 Nov 2 -7967.9957 37050.23 -1548.2323 Dec 2 -17642.3980 36929.63 -900.2315 Jan 3 12659.1390 36809.03 1087.8300 Feb 3 7700.9285 36945.35 -745.2807 Mar 3 13287.5150 37081.67 -1797.1885 Apr 3 8768.6005 37402.29 -2271.8906 May 3 1293.4826 37722.91 -1484.3892 Jun 3 3329.3779 38109.71 -1082.0889 Jul 3 -4897.9240 38496.52 1890.4086 Aug 3 -9623.8548 39027.92 -377.0626 Sep 3 -6667.3817 39559.32 1593.0622 Oct 3 -239.4873 40117.16 2720.3308 Nov 3 -7967.9957 40674.99 -2400.9978 Dec 3 -17642.3980 40903.88 3189.5227 Jan 4 12659.1390 41132.76 -6331.8961 Feb 4 7700.9285 41070.50 1332.5685 Mar 4 13287.5150 41008.25 7169.2361 Apr 4 8768.6005 40937.12 4020.2773 May 4 1293.4826 40866.00 -2682.4781 Jun 4 3329.3779 40790.45 -224.8237 Jul 4 -4897.9240 40714.90 -4335.9722 Aug 4 -9623.8548 40480.13 -960.2766 Sep 4 -6667.3817 40245.37 264.0149 Oct 4 -239.4873 40073.59 -714.1060 Nov 4 -7967.9957 39901.82 1768.1760 Dec 4 -17642.3980 40046.96 2689.4331 Jan 5 12659.1390 40192.11 -1409.2491 Feb 5 7700.9285 40362.45 -2469.3740 Mar 5 13287.5150 40532.78 -1302.2958 Apr 5 8768.6005 40579.83 -784.4264 May 5 1293.4826 40626.87 -175.3536 Jun 5 3329.3779 40661.93 5593.6918 Jul 5 -4897.9240 40696.99 -3052.0657 Aug 5 -9623.8548 40741.73 2261.1290 Sep 5 -6667.3817 40786.46 1525.9197 Oct 5 -239.4873 40827.69 -3554.2068 Nov 5 -7967.9957 40868.93 2780.0696 Dec 5 -17642.3980 40900.56 -2286.1620 > 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/1hj5k1259943649.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/2xmcu1259943649.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/3m3re1259943649.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/4fdwu1259943649.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/56q7c1259943649.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/68ki41259943649.tab") > system("convert tmp/1hj5k1259943649.ps tmp/1hj5k1259943649.png") > system("convert tmp/2xmcu1259943649.ps tmp/2xmcu1259943649.png") > system("convert tmp/3m3re1259943649.ps tmp/3m3re1259943649.png") > system("convert tmp/4fdwu1259943649.ps tmp/4fdwu1259943649.png") > > > proc.time() user system elapsed 0.992 0.625 4.823