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.2,8.0,7.5,6.8,6.5,6.6,7.6,8.0,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.351821216 7.285286 0.562892323 Feb 1 0.406846050 7.318404 0.274749671 Mar 1 0.245204361 7.351522 -0.096726457 Apr 1 0.005809651 7.383530 -0.589339352 May 1 -0.233585285 7.415537 -0.681952022 Jun 1 -0.394824681 7.440760 -0.445934988 Jul 1 0.077269175 7.465982 0.056748793 Aug 1 0.089158504 7.490262 0.420579400 Sep 1 0.025821591 7.514542 0.559636248 Oct 1 -0.185373225 7.560870 0.324503310 Nov 1 -0.296568194 7.607198 0.189370524 Dec 1 -0.091579025 7.622242 0.069337477 Jan 2 0.351821216 7.637285 -0.189106641 Feb 2 0.406846050 7.615579 -0.222425049 Mar 2 0.245204361 7.593873 -0.039076934 Apr 2 0.005809651 7.585308 -0.091117154 May 2 -0.233585285 7.576742 0.156842851 Jun 2 -0.394824681 7.599006 -0.104181570 Jul 2 0.077269175 7.621270 -0.198539242 Aug 2 0.089158504 7.657535 -0.246693665 Sep 2 0.025821591 7.693800 -0.119621847 Oct 2 -0.185373225 7.734023 0.151350443 Nov 2 -0.296568194 7.774245 0.222322886 Dec 2 -0.091579025 7.785241 0.206338201 Jan 3 0.351821216 7.796236 -0.048057556 Feb 3 0.406846050 7.747946 0.045208330 Mar 3 0.245204361 7.699655 0.255140739 Apr 3 0.005809651 7.618352 0.575838732 May 3 -0.233585285 7.537048 0.596536951 Jun 3 -0.394824681 7.450390 0.244434832 Jul 3 0.077269175 7.363731 -0.541000540 Aug 3 0.089158504 7.267264 -0.756422905 Sep 3 0.025821591 7.170797 -0.496619028 Oct 3 -0.185373225 7.083650 0.001723655 Nov 3 -0.296568194 6.996502 0.300066491 Dec 3 -0.091579025 6.949826 0.241753183 Jan 4 0.351821216 6.903150 -0.054971196 Feb 4 0.406846050 6.876077 -0.182922665 Mar 4 0.245204361 6.849003 -0.194207612 Apr 4 0.005809651 6.804313 0.189877514 May 4 -0.233585285 6.759622 0.273962865 Jun 4 -0.394824681 6.712802 0.082022291 Jul 4 0.077269175 6.665982 -0.043251535 Aug 4 0.089158504 6.622158 -0.111316138 Sep 4 0.025821591 6.578333 -0.204154499 Oct 4 -0.185373225 6.524770 -0.039396939 Nov 4 -0.296568194 6.471207 0.025360775 Dec 4 -0.091579025 6.447530 0.144048911 Jan 5 0.351821216 6.423853 0.024325977 Feb 5 0.406846050 6.444403 -0.051249360 Mar 5 0.245204361 6.464954 -0.310158173 Apr 5 0.005809651 6.479364 -0.385173714 May 5 -0.233585285 6.493774 -0.460189030 Jun 5 -0.394824681 6.504799 -0.009974075 Jul 5 0.077269175 6.515823 0.606907628 Aug 5 0.089158504 6.575916 0.634925902 Sep 5 0.025821591 6.636008 0.238170417 Oct 5 -0.185373225 6.738608 -0.453234345 Nov 5 -0.296568194 6.841207 -0.744638954 Dec 5 -0.091579025 6.967671 -0.676092134 Jan 6 0.351821216 7.094135 -0.345956385 Feb 6 0.406846050 7.219230 0.073923491 Mar 6 0.245204361 7.344326 0.310469890 Apr 6 0.005809651 7.477854 0.216336289 May 6 -0.233585285 7.611382 0.022202913 Jun 6 -0.394824681 7.752866 0.141958192 Jul 6 0.077269175 7.894351 0.028380218 Aug 6 0.089158504 8.040073 -0.029231323 > m$win s t l 681 19 13 > m$deg s t l 0 1 1 > m$jump s t l 69 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1d1wb1259784584.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/2akev1259784584.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/30avm1259784584.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/4u9c41259784584.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/5kxpb1259784584.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/6ogoh1259784584.tab") > system("convert tmp/1d1wb1259784584.ps tmp/1d1wb1259784584.png") > system("convert tmp/2akev1259784584.ps tmp/2akev1259784584.png") > system("convert tmp/30avm1259784584.ps tmp/30avm1259784584.png") > system("convert tmp/4u9c41259784584.ps tmp/4u9c41259784584.png") > > > proc.time() user system elapsed 0.978 0.619 2.311