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(1258,1199,1158,1427,934,709,1186,986,1033,1257,1105,1179,1092,1092,1087,2028,2039,2010,754,760,715,855,971,815,915,843,761,1858,2968,4061,3661,3269,2857,2568,2274,1987,683,381,71,1772,3485,5181,4479,3782,3067,2489,1903,1330,736,483,242,1334,2423,3523,2986,2462,1908,1575,1237,904) > 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 -776.12521 1404.910 629.215564 Feb 1 -927.54369 1345.281 781.262627 Mar 1 -1077.56218 1285.652 949.909703 Apr 1 -69.31861 1250.455 245.863787 May 1 604.92505 1215.257 -886.182212 Jun 1 1335.58516 1192.764 -1819.349473 Jul 1 855.64466 1170.271 -839.916116 Aug 1 513.67051 1146.044 -673.714812 Sep 1 197.29630 1121.817 -286.113438 Oct 1 36.03704 1173.012 47.951379 Nov 1 -208.82212 1224.206 89.616101 Dec 1 -483.78601 1297.868 364.917766 Jan 2 -776.12521 1371.530 496.594740 Feb 2 -927.54369 1358.077 661.467022 Mar 2 -1077.56218 1344.623 819.939316 Apr 2 -69.31861 1284.213 813.105940 May 2 604.92505 1223.802 210.272481 Jun 2 1335.58516 1167.202 -492.787655 Jul 2 855.64466 1110.603 -1212.247171 Aug 2 513.67051 1085.713 -839.383606 Sep 2 197.29630 1060.824 -543.119971 Oct 2 36.03704 1115.884 -296.920971 Nov 2 -208.82212 1170.944 8.877934 Dec 2 -483.78601 1332.314 -33.528305 Jan 3 -776.12521 1493.684 197.440764 Feb 3 -927.54369 1691.518 79.025286 Mar 3 -1077.56218 1889.352 -50.790181 Apr 3 -69.31861 2040.662 -113.342901 May 3 604.92505 2191.971 171.104296 Jun 3 1335.58516 2264.681 460.733700 Jul 3 855.64466 2337.392 467.963723 Aug 3 513.67051 2326.692 428.637454 Sep 3 197.29630 2315.992 343.711256 Oct 3 36.03704 2286.454 245.509061 Nov 3 -208.82212 2256.915 225.906772 Dec 3 -483.78601 2274.351 196.435395 Jan 4 -776.12521 2291.786 -832.660672 Feb 4 -927.54369 2340.689 -1032.144867 Mar 4 -1077.56218 2389.591 -1241.029050 Apr 4 -69.31861 2428.110 -586.791201 May 4 604.92505 2466.628 413.446565 Jun 4 1335.58516 2484.781 1360.633915 Jul 4 855.64466 2502.933 1120.421885 Aug 4 513.67051 2485.378 782.951793 Sep 4 197.29630 2467.822 401.881773 Oct 4 36.03704 2378.300 74.662664 Nov 4 -208.82212 2288.779 -176.956539 Dec 4 -483.78601 2158.995 -345.209168 Jan 5 -776.12521 2029.212 -517.086489 Feb 5 -927.54369 1930.771 -520.227256 Mar 5 -1077.56218 1832.330 -512.768011 Apr 5 -69.31861 1797.343 -394.023920 May 5 604.92505 1762.355 55.720087 Jun 5 1335.58516 1729.522 457.892834 Jul 5 855.64466 1696.689 433.666202 Aug 5 513.67051 1672.020 276.309969 Sep 5 197.29630 1647.350 63.353807 Oct 5 36.03704 1625.399 -86.436453 Nov 5 -208.82212 1603.449 -157.626807 Dec 5 -483.78601 1580.567 -192.781012 > 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/1num91259941828.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/2odus1259941828.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/35olb1259941828.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/4x8pb1259941828.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/5fy231259941828.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/6jqas1259941828.tab") > system("convert tmp/1num91259941828.ps tmp/1num91259941828.png") > system("convert tmp/2odus1259941828.ps tmp/2odus1259941828.png") > system("convert tmp/35olb1259941828.ps tmp/35olb1259941828.png") > system("convert tmp/4x8pb1259941828.ps tmp/4x8pb1259941828.png") > > > proc.time() user system elapsed 0.964 0.614 1.136