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(14.9,18.6,19.1,18.8,18.2,18,19,20.7,21.2,20.7,19.6,18.6,18.7,23.8,24.9,24.8,23.8,22.3,21.7,20.7,19.7,18.4,17.4,17,18,23.8,25.5,25.6,23.7,22,21.3,20.7,20.4,20.3,20.4,19.8,19.5,23.1,23.5,23.5,22.9,21.9,21.5,20.5,20.2,19.4,19.2,18.8,18.8,22.6,23.3,23,21.4,19.9,18.8,18.6,18.4,18.6,19.9,19.2,18.4) > 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 -2.1791726 15.89579 1.18337822 Feb 1 2.0694673 16.43811 0.09242487 Mar 1 2.8503675 16.98042 -0.73078875 Apr 1 2.6500956 17.50493 -1.35502693 May 1 1.4298234 18.02944 -1.25926483 Jun 1 0.1790853 18.52611 -0.70519863 Jul 1 -0.2516528 19.02279 0.22886754 Aug 1 -0.5281403 19.51355 1.71459220 Sep 1 -0.8446272 20.00431 2.04031641 Oct 1 -1.4086954 20.48708 1.62161342 Nov 1 -1.6527635 20.96985 0.28291039 Dec 1 -2.3137873 21.25179 -0.33800336 Jan 2 -2.1791726 21.53373 -0.65455569 Feb 2 2.0694673 21.58825 0.14227977 Mar 2 2.8503675 21.64278 0.40685496 Apr 2 2.6500956 21.54173 0.60817818 May 2 1.4298234 21.44067 0.92950168 Jun 2 0.1790853 21.30368 0.81723458 Jul 2 -0.2516528 21.16669 0.78496745 Aug 2 -0.5281403 21.08204 0.14610211 Sep 2 -0.8446272 20.99739 -0.45276369 Oct 2 -1.4086954 20.98835 -1.17965360 Nov 2 -1.6527635 20.97931 -1.92654355 Dec 2 -2.3137873 21.01840 -1.70461240 Jan 3 -2.1791726 21.05749 -0.87831983 Feb 3 2.0694673 21.14840 0.58212779 Mar 3 2.8503675 21.23932 1.41031514 Apr 3 2.6500956 21.39353 1.55637570 May 3 1.4298234 21.54774 0.72243655 Jun 3 0.1790853 21.66660 0.15431507 Jul 3 -0.2516528 21.78546 -0.23380645 Aug 3 -0.5281403 21.75727 -0.52912505 Sep 3 -0.8446272 21.72907 -0.48444412 Oct 3 -1.4086954 21.63305 0.07564495 Nov 3 -1.6527635 21.53703 0.51573398 Dec 3 -2.3137873 21.49388 0.61990262 Jan 4 -2.1791726 21.45074 0.22843268 Feb 4 2.0694673 21.42636 -0.39582408 Mar 4 2.8503675 21.40197 -0.75234111 Apr 4 2.6500956 21.34486 -0.49495907 May 4 1.4298234 21.28775 0.18242325 Jun 4 0.1790853 21.22710 0.49381537 Jul 4 -0.2516528 21.16645 0.58520744 Aug 4 -0.5281403 21.12095 -0.09280850 Sep 4 -0.8446272 21.07545 -0.03082491 Oct 4 -1.4086954 20.99595 -0.18725181 Nov 4 -1.6527635 20.91644 -0.06367874 Dec 4 -2.3137873 20.77183 0.34195242 Jan 5 -2.1791726 20.62723 0.35194500 Feb 5 2.0694673 20.46838 0.06215731 Mar 5 2.8503675 20.30952 0.14010934 Apr 5 2.6500956 20.24942 0.10047975 May 5 1.4298234 20.18933 -0.21914956 Jun 5 0.1790853 20.20885 -0.48793289 Jul 5 -0.2516528 20.22837 -1.17671626 Aug 5 -0.5281403 20.24377 -1.11562603 Sep 5 -0.8446272 20.25916 -1.01453627 Oct 5 -1.4086954 20.28514 -0.27644791 Nov 5 -1.6527635 20.31112 1.24164041 Dec 5 -2.3137873 20.35939 1.15439462 Jan 6 -2.1791726 20.40766 0.17151024 > 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/14mww1259953114.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/22r2m1259953114.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/3nseo1259953114.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/4kbws1259953114.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/5jh0y1259953114.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/6btq81259953114.tab") > system("convert tmp/14mww1259953114.ps tmp/14mww1259953114.png") > system("convert tmp/22r2m1259953114.ps tmp/22r2m1259953114.png") > system("convert tmp/3nseo1259953114.ps tmp/3nseo1259953114.png") > system("convert tmp/4kbws1259953114.ps tmp/4kbws1259953114.png") > > > proc.time() user system elapsed 0.991 0.631 1.247