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(5.7,6.1,6,5.9,5.8,5.7,5.6,5.4,5.4,5.5,5.6,5.7,5.9,6.1,6,5.8,5.8,5.7,5.5,5.3,5.2,5.2,5,5.1,5.1,5.2,4.9,4.8,4.5,4.5,4.4,4.4,4.2,4.1,3.9,3.8,3.9,4.2,4.1,3.8,3.6,3.7,3.5,3.4,3.1,3.1,3.1,3.2,3.3,3.5,3.6,3.5,3.3,3.2,3.1,3.2,3,3,3.1,3.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 0.08203130 5.674068 -0.056099318 Feb 1 0.36167990 5.678053 0.060267239 Mar 1 0.30132846 5.682038 0.016633836 Apr 1 0.17236848 5.686820 0.040811175 May 1 0.04340851 5.691603 0.064988502 Jun 1 0.03205770 5.696968 -0.029025877 Jul 1 -0.07929319 5.702333 -0.023040177 Aug 1 -0.12864249 5.706646 -0.178003575 Sep 1 -0.25799183 5.710959 -0.052966933 Oct 1 -0.22063196 5.712232 0.008399822 Nov 1 -0.22327218 5.713506 0.109766656 Dec 1 -0.08304267 5.711879 0.071163951 Jan 2 0.08203130 5.710252 0.107716791 Feb 2 0.36167990 5.698381 0.039938900 Mar 2 0.30132846 5.686510 0.012161048 Apr 2 0.17236848 5.655073 -0.027441543 May 2 0.04340851 5.623636 0.132955853 Jun 2 0.03205770 5.571111 0.096831380 Jul 2 -0.07929319 5.518586 0.060706985 Aug 2 -0.12864249 5.444522 -0.015879055 Sep 2 -0.25799183 5.370457 0.087534944 Oct 2 -0.22063196 5.277390 0.143242448 Nov 2 -0.22327218 5.184322 0.038950030 Dec 2 -0.08304267 5.084561 0.098482057 Jan 3 0.08203130 4.984799 0.033169629 Feb 3 0.36167990 4.892439 -0.054119288 Mar 3 0.30132846 4.800080 -0.201408166 Apr 3 0.17236848 4.711287 -0.083655512 May 3 0.04340851 4.622494 -0.165902871 Jun 3 0.03205770 4.533599 -0.065656548 Jul 3 -0.07929319 4.444703 0.034589854 Aug 3 -0.12864249 4.361401 0.167241521 Sep 3 -0.25799183 4.278099 0.179893226 Oct 3 -0.22063196 4.198545 0.122086478 Nov 3 -0.22327218 4.118992 0.004279807 Dec 3 -0.08304267 4.038212 -0.155169482 Jan 4 0.08203130 3.957432 -0.139463226 Feb 4 0.36167990 3.875862 -0.037541770 Mar 4 0.30132846 3.794292 0.004379726 Apr 4 0.17236848 3.721883 -0.094251617 May 4 0.04340851 3.649474 -0.092882973 Jun 4 0.03205770 3.590803 0.077139023 Jul 4 -0.07929319 3.532132 0.047161098 Aug 4 -0.12864249 3.483715 0.044927595 Sep 4 -0.25799183 3.435298 -0.077305869 Oct 4 -0.22063196 3.397066 -0.076433668 Nov 4 -0.22327218 3.358834 -0.035561389 Dec 4 -0.08304267 3.328946 -0.045903191 Jan 5 0.08203130 3.299058 -0.081089448 Feb 5 0.36167990 3.280351 -0.142031044 Mar 5 0.30132846 3.261644 0.037027398 Apr 5 0.17236848 3.263851 0.063780659 May 5 0.04340851 3.266058 -0.009466094 Jun 5 0.03205770 3.272386 -0.104444143 Jul 5 -0.07929319 3.278715 -0.099422114 Aug 5 -0.12864249 3.286063 0.042579005 Sep 5 -0.25799183 3.293412 -0.035419836 Oct 5 -0.22063196 3.301910 -0.081278465 Nov 5 -0.22327218 3.310409 0.012862984 Dec 5 -0.08304267 3.320074 0.162968540 > 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/1kzuv1259917616.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/2yjtq1259917616.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/3hfs51259917616.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/4qdoy1259917616.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/5u60f1259917616.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/63w6n1259917616.tab") > system("convert tmp/1kzuv1259917616.ps tmp/1kzuv1259917616.png") > system("convert tmp/2yjtq1259917616.ps tmp/2yjtq1259917616.png") > system("convert tmp/3hfs51259917616.ps tmp/3hfs51259917616.png") > system("convert tmp/4qdoy1259917616.ps tmp/4qdoy1259917616.png") > > > proc.time() user system elapsed 0.950 0.602 3.299