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(519,517,510,509,501,507,569,580,578,565,547,555,562,561,555,544,537,543,594,611,613,611,594,595,591,589,584,573,567,569,621,629,628,612,595,597,593,590,580,574,573,573,620,626,620,588,566,557,561,549,532,526,511,499,555,565,542,527,510,514,517,508,493,490,469,478,528,534,518,506,502,516) > 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 0.3144649 518.7106 -0.02503044 Feb 1 -4.4539711 522.2917 -0.83777506 Mar 1 -14.3890735 525.8729 -1.48385329 Apr 1 -20.6640125 529.4122 0.25183237 May 1 -30.2722763 532.9514 -1.67915708 Jun 1 -28.3537571 536.4516 -1.09784028 Jul 1 24.7314296 539.9518 4.31680901 Aug 1 34.6530482 543.4504 1.89655465 Sep 1 27.2413358 546.9490 3.80963136 Oct 1 12.6755664 550.2662 2.05825177 Nov 1 -2.7235361 553.5833 -3.85979471 Dec 1 1.2407802 556.3318 -2.57255559 Jan 2 0.3144649 559.0802 2.60531503 Feb 2 -4.4539711 561.7815 3.67245640 Mar 2 -14.3890735 564.4828 4.90626418 Apr 2 -20.6640125 567.6892 -3.02517281 May 2 -30.2722763 570.8956 -3.62328489 Jun 2 -28.3537571 574.1164 -2.76267169 Jul 2 24.7314296 577.3373 -8.06872599 Aug 2 34.6530482 580.1408 -3.79382310 Sep 2 27.2413358 582.9443 2.81441086 Oct 2 12.6755664 585.5065 12.81791853 Nov 2 -2.7235361 588.0688 8.65475932 Dec 2 1.2407802 590.2074 3.55177680 Jan 3 0.3144649 592.3461 -1.66057420 Feb 3 -4.4539711 593.6433 -0.18932337 Mar 3 -14.3890735 594.9405 3.44859387 Apr 3 -20.6640125 595.4757 -1.81172796 May 3 -30.2722763 596.0110 1.26127510 Jun 3 -28.3537571 596.2279 1.12588402 Jul 3 24.7314296 596.4447 -0.17617458 Aug 3 34.6530482 596.4784 -2.13143447 Sep 3 27.2413358 596.5120 4.24663670 Oct 3 12.6755664 596.5342 2.79018747 Nov 3 -2.7235361 596.5565 1.16707137 Dec 3 1.2407802 596.6299 -0.87066235 Jan 4 0.3144649 596.7033 -4.01776455 Feb 4 -4.4539711 596.3715 -1.91748879 Mar 4 -14.3890735 596.0396 -1.65054664 Apr 4 -20.6640125 594.6472 0.01683113 May 4 -30.2722763 593.2547 10.01753381 Jun 4 -28.3537571 590.6638 10.68993421 Jul 4 24.7314296 588.0729 7.19566709 Aug 4 34.6530482 584.3603 6.98669105 Sep 4 27.2413358 580.6476 12.11104608 Oct 4 12.6755664 575.8742 -0.54980497 Nov 4 -2.7235361 571.1009 -2.37732289 Dec 4 1.2407802 565.5752 -9.81600444 Jan 5 0.3144649 560.0496 0.63594553 Feb 5 -4.4539711 554.5185 -1.06453518 Mar 5 -14.3890735 548.9874 -2.59834950 Apr 5 -20.6640125 543.9588 2.70521907 May 5 -30.2722763 538.9302 2.34211253 Jun 5 -28.3537571 534.7329 -7.37918040 Jul 5 24.7314296 530.5357 -0.26714085 Aug 5 34.6530482 526.9875 3.35946940 Sep 5 27.2413358 523.4393 -8.68058929 Oct 5 12.6755664 520.4501 -6.12564155 Nov 5 -2.7235361 517.4609 -4.73736069 Dec 5 1.2407802 515.0477 -2.28847633 Jan 6 0.3144649 512.6345 4.05103954 Feb 6 -4.4539711 510.5992 1.85476354 Mar 6 -14.3890735 508.5639 -1.17484607 Apr 6 -20.6640125 507.2532 3.41083798 May 6 -30.2722763 505.9424 -6.67015307 Jun 6 -28.3537571 505.0030 1.35071607 Jul 6 24.7314296 504.0637 -0.79508230 Aug 6 34.6530482 503.1419 -3.79495382 Sep 6 27.2413358 502.2202 -11.46149428 Oct 6 12.6755664 501.3192 -7.99477730 Nov 6 -2.7235361 500.4183 4.30527279 Dec 6 1.2407802 499.5894 15.16980125 > m$win s t l 721 19 13 > m$deg s t l 0 1 1 > m$jump s t l 73 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1spio1259786903.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/2jb8h1259786903.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/3grs81259786903.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/4wep41259786903.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/5g0pi1259786903.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/6jevb1259786903.tab") > > system("convert tmp/1spio1259786903.ps tmp/1spio1259786903.png") > system("convert tmp/2jb8h1259786903.ps tmp/2jb8h1259786903.png") > system("convert tmp/3grs81259786903.ps tmp/3grs81259786903.png") > system("convert tmp/4wep41259786903.ps tmp/4wep41259786903.png") > > > proc.time() user system elapsed 0.990 0.586 1.193