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(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,528,533,536,537,524,536,587,597,581,564) > par8 = 'FALSE' > par7 = '1' > par6 = '' > par5 = '1' > par4 = '' > par3 = '1' > 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 6.34954020 596.8516 7.7988546 Feb 1 -5.78724544 596.6443 3.1429025 Mar 1 -2.72507555 596.4371 1.2879948 Apr 1 0.01815552 596.3367 -5.3549034 May 1 -3.63861752 596.2364 -3.5977975 Jun 1 -11.82183452 596.1890 -0.3671475 Jul 1 -16.20504480 596.1415 -6.9365042 Aug 1 -26.94940371 596.1195 -2.1700613 Sep 1 -24.29376622 596.0974 -2.8036148 Oct 1 27.06547288 596.3590 -2.4244946 Nov 1 35.22471111 596.6207 -2.8453736 Dec 1 22.76310542 596.7548 8.4821133 Jan 2 6.34954020 596.8889 8.7615597 Feb 2 -5.78724544 596.9472 3.8400924 Mar 2 -2.72507555 597.0054 2.7196697 Apr 2 0.01815552 596.7389 -3.7570374 May 2 -3.63861752 596.4724 -2.8337403 Jun 2 -11.82183452 595.5124 -3.6905599 Jul 2 -16.20504480 594.5524 -4.3473863 Aug 2 -26.94940371 592.5875 7.3619262 Sep 2 -24.29376622 590.6225 6.6712423 Oct 2 27.06547288 587.6729 5.2616525 Nov 2 35.22471111 584.7232 6.0520636 Dec 2 22.76310542 580.6287 16.6081589 Jan 3 6.34954020 576.5342 5.1162137 Feb 3 -5.78724544 571.2671 0.5201736 Mar 3 -2.72507555 565.9999 -6.2748220 Apr 3 0.01815552 560.1841 0.7977420 May 3 -3.63861752 554.3683 -1.7296899 Jun 3 -11.82183452 548.8585 -5.0366782 Jul 3 -16.20504480 543.3487 -1.1436733 Aug 3 -26.94940371 538.7858 -0.8364267 Sep 3 -24.29376622 534.2229 -10.9291765 Oct 3 27.06547288 530.5765 -2.6419700 Nov 3 35.22471111 526.9301 2.8452374 Dec 3 22.76310542 523.8200 -4.5831014 Jan 4 6.34954020 520.7099 -0.0594807 Feb 4 -5.78724544 517.9761 -2.1888871 Mar 4 -2.72507555 515.2423 1.4827509 Apr 4 0.01815552 512.8493 4.1325809 May 4 -3.63861752 510.4562 1.1824150 Jun 4 -11.82183452 508.4375 -3.6157090 Jul 4 -16.20504480 506.4189 -0.2138396 Aug 4 -26.94940371 505.4697 -9.5202753 Sep 4 -24.29376622 504.5205 -2.2267074 Oct 4 27.06547288 505.4312 -4.4966229 Nov 4 35.22471111 506.3418 -7.5665375 Dec 4 22.76310542 509.4476 -14.2106839 Jan 5 6.34954020 512.5533 -12.9028708 Feb 5 -5.78724544 517.2595 -9.4722924 Mar 5 -2.72507555 521.9657 -3.2406695 Apr 5 0.01815552 527.2814 0.7004102 May 5 -3.63861752 532.5971 4.0414941 Jun 5 -11.82183452 537.4387 10.3831122 Jul 5 -16.20504480 542.2803 10.9247236 Aug 5 -26.94940371 547.1104 3.8389795 Sep 5 -24.29376622 551.9405 8.3532390 Oct 5 27.06547288 556.6757 3.2587968 Nov 5 35.22471111 561.4109 0.3643555 Dec 5 22.76310542 565.9430 -7.7061171 Jan 6 6.34954020 570.4751 -12.8246303 > m$win s t l 611 19 13 > m$deg s t l 0 1 1 > m$jump s t l 62 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1wo3a1259953674.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/2xyaq1259953674.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/3smr21259953674.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/4a2p01259953674.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/57vaz1259953675.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/6g7rl1259953675.tab") > system("convert tmp/1wo3a1259953674.ps tmp/1wo3a1259953674.png") > system("convert tmp/2xyaq1259953674.ps tmp/2xyaq1259953674.png") > system("convert tmp/3smr21259953674.ps tmp/3smr21259953674.png") > system("convert tmp/4a2p01259953674.ps tmp/4a2p01259953674.png") > > > proc.time() user system elapsed 0.968 0.604 1.122