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(8.1,7.7,7.5,7.6,7.8,7.8,7.8,7.5,7.5,7.1,7.5,7.5,7.6,7.7,7.7,7.9,8.1,8.2,8.2,8.2,7.9,7.3,6.9,6.6,6.7,6.9,7.0,7.1,7.2,7.1,6.9,7.0,6.8,6.4,6.7,6.6,6.4,6.3,6.2,6.5,6.8,6.8,6.4,6.1,5.8,6.1,7.2,7.3,6.9,6.1,5.8,6.2,7.1,7.7,7.9,7.7,7.4,7.5,8.0,8.1) > 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.02917189 7.837011 0.292160573 Feb 1 -0.22399717 7.798783 0.125214394 Mar 1 -0.31882267 7.760554 0.058268438 Apr 1 -0.10280326 7.728669 -0.025865798 May 1 0.23321599 7.696784 -0.129999877 Jun 1 0.34800698 7.670051 -0.218057736 Jul 1 0.26279799 7.643318 -0.106115608 Aug 1 0.12540298 7.620719 -0.246122083 Sep 1 -0.09199220 7.598121 -0.006128389 Oct 1 -0.29688641 7.607527 -0.210640477 Nov 1 0.07821939 7.616933 -0.195152566 Dec 1 0.01603077 7.657075 -0.173105348 Jan 2 -0.02917189 7.697216 -0.068044084 Feb 2 -0.22399717 7.739976 0.184021575 Mar 2 -0.31882267 7.782735 0.236087457 Apr 2 -0.10280326 7.791123 0.211679803 May 2 0.23321599 7.799512 0.067272305 Jun 2 0.34800698 7.747540 0.104452895 Jul 2 0.26279799 7.695569 0.241633472 Aug 2 0.12540298 7.612913 0.461683561 Sep 2 -0.09199220 7.530258 0.461733818 Oct 2 -0.29688641 7.444826 0.152059971 Nov 2 0.07821939 7.359394 -0.537613876 Dec 2 0.01603077 7.266804 -0.682834594 Jan 3 -0.02917189 7.174213 -0.445041265 Feb 3 -0.22399717 7.089602 0.034394792 Mar 3 -0.31882267 7.004992 0.313831071 Apr 3 -0.10280326 6.955708 0.247094790 May 3 0.23321599 6.906425 0.060358666 Jun 3 0.34800698 6.875671 -0.123678103 Jul 3 0.26279799 6.844917 -0.207714884 Aug 3 0.12540298 6.798875 0.075722336 Sep 3 -0.09199220 6.752832 0.139159725 Oct 3 -0.29688641 6.707239 -0.010352575 Nov 3 0.07821939 6.661645 -0.039864876 Dec 3 0.01603077 6.621697 -0.037727827 Jan 4 -0.02917189 6.581749 -0.152576731 Feb 4 -0.22399717 6.530723 -0.006725793 Mar 4 -0.31882267 6.479697 0.039125366 Apr 4 -0.10280326 6.453413 0.149390525 May 4 0.23321599 6.427128 0.139655841 Jun 4 0.34800698 6.443998 0.007995201 Jul 4 0.26279799 6.460867 -0.323665452 Aug 4 0.12540298 6.473926 -0.499328899 Sep 4 -0.09199220 6.486984 -0.594992177 Oct 4 -0.29688641 6.499235 -0.102348947 Nov 4 0.07821939 6.511486 0.610294282 Dec 4 0.01603077 6.575455 0.708514212 Jan 5 -0.02917189 6.639424 0.289748188 Feb 5 -0.22399717 6.744560 -0.420563194 Mar 5 -0.31882267 6.849697 -0.730874355 Apr 5 -0.10280326 6.970083 -0.667279547 May 5 0.23321599 7.090469 -0.223684583 Jun 5 0.34800698 7.212342 0.139651385 Jul 5 0.26279799 7.334215 0.302987339 Aug 5 0.12540298 7.463332 0.111265052 Sep 5 -0.09199220 7.592449 -0.100457064 Oct 5 -0.29688641 7.728202 0.068684559 Nov 5 0.07821939 7.863954 0.057826181 Dec 5 0.01603077 8.003657 0.080311956 > 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/1hphc1259775859.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/2npf11259775859.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/30mzq1259775859.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/4cpz01259775859.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/5ovyz1259775860.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/6zyv31259775860.tab") > system("convert tmp/1hphc1259775859.ps tmp/1hphc1259775859.png") > system("convert tmp/2npf11259775859.ps tmp/2npf11259775859.png") > system("convert tmp/30mzq1259775859.ps tmp/30mzq1259775859.png") > system("convert tmp/4cpz01259775859.ps tmp/4cpz01259775859.png") > > > proc.time() user system elapsed 0.969 0.605 1.131