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(1915,1843,1761,2858,3968,5061,4661,4269,3857,3568,3274,2987,1683,1381,1071,2772,4485,6181,5479,4782,4067,3489,2903,2330,1736,1483,1242,2334,3423,4523,3986,3462,2908,2575,2237,1904,1610,1251,941,2450,3946,5409,4741,4069,3539,3189,2960,2704,1697,1598,1456,2316,3083,4158,3469,2892,2578,2233,1947,2049) > 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 -1350.68353 3329.505 -63.821709 Feb 1 -1547.31074 3324.102 66.208992 Mar 1 -1743.93793 3318.698 186.239672 Apr 1 -476.14822 3313.129 21.019334 May 1 774.84151 3307.560 -114.401023 Jun 1 2073.64146 3299.874 -312.515585 Jul 1 1487.84123 3292.189 -119.029979 Aug 1 932.34640 3280.925 55.729094 Sep 1 444.25152 3269.660 143.088222 Oct 1 92.92976 3268.375 206.695552 Nov 1 -225.99201 3267.089 232.902881 Dec 1 -461.77960 3305.649 143.130859 Jan 2 -1350.68353 3344.208 -310.524828 Feb 2 -1547.31074 3386.355 -458.044593 Mar 2 -1743.93793 3428.502 -613.564380 Apr 2 -476.14822 3443.991 -195.842585 May 2 774.84151 3459.479 250.679189 Jun 2 2073.64146 3456.772 650.586163 Jul 2 1487.84123 3454.065 537.093304 Aug 2 932.34640 3438.104 411.549213 Sep 2 444.25152 3422.143 200.605177 Oct 2 92.92976 3360.548 35.522381 Nov 2 -225.99201 3298.952 -169.960415 Dec 2 -461.77960 3190.293 -398.513665 Jan 3 -1350.68353 3081.634 5.049422 Feb 3 -1547.31074 2976.438 53.873066 Mar 3 -1743.93793 2871.241 114.696688 Apr 3 -476.14822 2796.505 13.643473 May 3 774.84151 2721.768 -73.609762 Jun 3 2073.64146 2677.450 -228.091928 Jul 3 1487.84123 2633.133 -134.973925 Aug 3 932.34640 2614.091 -84.437895 Sep 3 444.25152 2595.050 -131.301811 Oct 3 92.92976 2612.612 -130.541636 Nov 3 -225.99201 2630.173 -167.181461 Dec 3 -461.77960 2683.863 -318.082921 Jan 4 -1350.68353 2737.552 223.131954 Feb 4 -1547.31074 2802.579 -4.268451 Mar 4 -1743.93793 2867.607 -182.668878 Apr 4 -476.14822 2927.185 -1.037019 May 4 774.84151 2986.764 184.394820 Jun 4 2073.64146 3031.950 303.408137 Jul 4 1487.84123 3077.137 176.021622 Aug 4 932.34640 3100.280 36.373870 Sep 4 444.25152 3123.422 -28.673826 Oct 4 92.92976 3104.404 -8.333799 Nov 4 -225.99201 3085.386 100.606228 Dec 4 -461.77960 3011.245 154.535072 Jan 5 -1350.68353 2937.103 110.580251 Feb 5 -1547.31074 2838.173 307.137342 Mar 5 -1743.93793 2739.244 460.694411 Apr 5 -476.14822 2648.771 143.377486 May 5 774.84151 2558.298 -250.139459 Jun 5 2073.64146 2475.671 -391.312590 Jul 5 1487.84123 2393.044 -411.885552 Aug 5 932.34640 2307.766 -348.112556 Sep 5 444.25152 2222.488 -88.739504 Oct 5 92.92976 2139.035 1.035084 Nov 5 -225.99201 2055.582 117.409673 Dec 5 -461.77960 1976.366 534.413386 > 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/1c4qm1259870937.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/23aum1259870937.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/3i3rd1259870937.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/4j2c31259870937.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/5zym61259870937.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/6beo01259870937.tab") > > system("convert tmp/1c4qm1259870937.ps tmp/1c4qm1259870937.png") > system("convert tmp/23aum1259870937.ps tmp/23aum1259870937.png") > system("convert tmp/3i3rd1259870937.ps tmp/3i3rd1259870937.png") > system("convert tmp/4j2c31259870937.ps tmp/4j2c31259870937.png") > > > proc.time() user system elapsed 0.951 0.618 1.118