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(1901,1395,1639,1643,1751,1797,1373,1558,1555,2061,2010,2119,1985,1963,2017,1975,1589,1679,1392,1511,1449,1767,1899,2179,2217,2049,2343,2175,1607,1702,1764,1766,1615,1953,2091,2411,2550,2351,2786,2525,2474,2332,1978,1789,1904,1997,2207,2453,1948,1384,1989,2140,2100,2045,2083,2022,1950,1422,1859,2147) > 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 218.21390 1519.375 163.410899 Feb 1 -85.64879 1556.677 -76.028671 Mar 1 228.68823 1593.980 -183.667953 Apr 1 160.27487 1629.294 -146.568420 May 1 -32.33859 1664.607 118.731213 Jun 1 -27.64047 1697.724 126.916826 Jul 1 -222.74233 1730.840 -135.097575 Aug 1 -214.79033 1763.266 9.524653 Sep 1 -252.63829 1795.691 11.946853 Oct 1 -114.77102 1819.306 356.465467 Nov 1 50.89609 1842.920 116.184249 Dec 1 292.49675 1840.068 -13.564491 Jan 2 218.21390 1837.216 -70.429728 Feb 2 -85.64879 1823.887 224.762012 Mar 2 228.68823 1810.558 -22.245960 Apr 2 160.27487 1796.457 18.268191 May 2 -32.33859 1782.356 -161.017558 Jun 2 -27.64047 1781.965 -75.324072 Jul 2 -222.74233 1781.573 -166.830600 Aug 2 -214.79033 1798.155 -72.364229 Sep 2 -252.63829 1814.736 -113.097886 Oct 2 -114.77102 1835.717 46.053745 Nov 2 50.89609 1856.698 -8.594457 Dec 2 292.49675 1874.692 11.811187 Jan 3 218.21390 1892.686 106.100335 Feb 3 -85.64879 1906.824 227.824777 Mar 3 228.68823 1920.962 193.349508 Apr 3 160.27487 1932.644 82.080995 May 3 -32.33859 1944.326 -304.987419 Jun 3 -27.64047 1959.206 -229.565727 Jul 3 -222.74233 1974.086 12.655952 Aug 3 -214.79033 2004.455 -23.664295 Sep 3 -252.63829 2034.823 -167.184570 Oct 3 -114.77102 2083.308 -15.536553 Nov 3 50.89609 2131.792 -91.688367 Dec 3 292.49675 2178.558 -60.054291 Jan 4 218.21390 2225.323 106.463290 Feb 4 -85.64879 2249.134 187.514809 Mar 4 228.68823 2272.945 284.366616 Apr 4 160.27487 2277.990 86.735422 May 4 -32.33859 2283.034 223.304328 Jun 4 -27.64047 2259.896 99.744929 Jul 4 -222.74233 2236.757 -36.014483 Aug 4 -214.79033 2183.247 -179.456460 Sep 4 -252.63829 2129.737 26.901535 Oct 4 -114.77102 2080.274 31.496979 Nov 4 50.89609 2030.811 125.292591 Dec 4 292.49675 2011.030 149.473194 Jan 5 218.21390 1991.249 -261.462699 Feb 5 -85.64879 1990.478 -520.829027 Mar 5 228.68823 1989.707 -229.395067 Apr 5 160.27487 1982.707 -2.981514 May 5 -32.33859 1975.706 156.632138 Jun 5 -27.64047 1968.685 103.955506 Jul 5 -222.74233 1961.663 344.078860 Aug 5 -214.79033 1958.013 278.777560 Sep 5 -252.63829 1954.362 248.276232 Oct 5 -114.77102 1950.167 -413.395920 Nov 5 50.89609 1945.972 -137.867903 Dec 5 292.49675 1939.418 -84.914633 > 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/1xm0b1260464194.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/2skrn1260464194.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/3sfe71260464194.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/4ct051260464194.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/5irvt1260464194.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/6qv951260464194.tab") > system("convert tmp/1xm0b1260464194.ps tmp/1xm0b1260464194.png") > system("convert tmp/2skrn1260464194.ps tmp/2skrn1260464194.png") > system("convert tmp/3sfe71260464194.ps tmp/3sfe71260464194.png") > system("convert tmp/4ct051260464194.ps tmp/4ct051260464194.png") > > > proc.time() user system elapsed 0.952 0.601 1.406