R version 2.8.0 (2008-10-20) Copyright (C) 2008 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. Natural language support but running in an English locale 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(16,17,23,24,27,31,40,47,43,60,64,65,65,55,57,57,57,65,69,70,71,71,73,68,65,57,41,21,21,17,9,11,6,-2,0,5,3,7,4,8,9,14,12,12,7,15,14,19,39,12,11,17,16,25,24,28,25,31,24,24) > 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 7.5696030 15.201598 -6.7712014 Feb 1 -0.9181536 19.254212 -1.3360579 Mar 1 -3.8059198 23.306825 3.4990951 Apr 1 -5.7955825 27.274424 2.5211589 May 1 -5.3852391 31.242022 1.1432166 Jun 1 -1.1079081 35.114536 -3.0066278 Jul 1 -0.8305783 38.987049 1.8435289 Aug 1 1.8064478 42.725338 2.4682143 Sep 1 -1.5565239 46.463626 -1.9071026 Oct 1 2.9686023 49.558863 7.4725343 Nov 1 2.8937370 52.654100 8.4521627 Dec 1 4.1615063 55.100939 5.7375552 Jan 2 7.5696030 57.547777 -0.1173797 Feb 2 -0.9181536 59.473475 -3.5553214 Mar 2 -3.8059198 61.399173 -0.5932535 Apr 2 -5.7955825 62.687176 0.1084068 May 2 -5.3852391 63.975178 -1.5899390 Jun 2 -1.1079081 64.579769 1.5281392 Jul 2 -0.8305783 65.184360 4.6462187 Aug 2 1.8064478 64.783611 3.4099411 Sep 2 -1.5565239 64.382863 8.1736614 Oct 2 2.9686023 62.171047 5.8603505 Nov 2 2.8937370 59.959232 10.1470312 Dec 2 4.1615063 55.880433 7.9580605 Jan 3 7.5696030 51.801635 5.6287625 Feb 3 -0.9181536 46.405292 11.5128613 Mar 3 -3.8059198 41.008950 3.7969696 Apr 3 -5.7955825 35.009784 -8.2142013 May 3 -5.3852391 29.010617 -2.6253784 Jun 3 -1.1079081 23.420841 -5.3129333 Jul 3 -0.8305783 17.831065 -8.0004871 Aug 3 1.8064478 13.839792 -4.6462396 Sep 3 -1.5565239 9.848518 -2.2919943 Oct 3 2.9686023 8.027704 -12.9963065 Nov 3 2.8937370 6.206890 -9.1006272 Dec 3 4.1615063 5.997501 -5.1590071 Jan 4 7.5696030 5.788111 -10.3577144 Feb 4 -0.9181536 6.398598 1.5195560 Mar 4 -3.8059198 7.009084 0.7968359 Apr 4 -5.7955825 8.065779 5.7298036 May 4 -5.3852391 9.122474 5.2627652 Jun 4 -1.1079081 10.432699 4.6752091 Jul 4 -0.8305783 11.742924 1.0876542 Aug 4 1.8064478 12.757892 -2.5643401 Sep 4 -1.5565239 13.772861 -5.2163366 Oct 4 2.9686023 14.518526 -2.4871278 Nov 4 2.8937370 15.264191 -4.1579275 Dec 4 4.1615063 16.223214 -1.3847207 Jan 5 7.5696030 17.182238 14.2481589 Feb 5 -0.9181536 18.474002 -5.5558482 Mar 5 -3.8059198 19.765766 -4.9598458 Apr 5 -5.7955825 20.601465 2.1941172 May 5 -5.3852391 21.437165 -0.0519260 Jun 5 -1.1079081 22.096466 4.0114425 Jul 5 -0.8305783 22.755766 2.0748121 Aug 5 1.8064478 23.391114 2.8024379 Sep 5 -1.5565239 24.026463 2.5300613 Oct 5 2.9686023 24.620607 3.4107904 Nov 5 2.8937370 25.214752 -4.1084890 Dec 5 4.1615063 25.753394 -5.9149008 > 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/freestat/rcomp/tmp/1oa741293646134.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/2oa741293646134.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/3oa741293646134.ps",horizontal=F,onefile=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/freestat/rcomp/tmp/4yj6p1293646134.ps",horizontal=F,onefile=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/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/5dbmg1293646134.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/freestat/rcomp/tmp/6gu2m1293646134.tab") > > try(system("convert tmp/1oa741293646134.ps tmp/1oa741293646134.png",intern=TRUE)) character(0) > try(system("convert tmp/2oa741293646134.ps tmp/2oa741293646134.png",intern=TRUE)) character(0) > try(system("convert tmp/3oa741293646134.ps tmp/3oa741293646134.png",intern=TRUE)) character(0) > try(system("convert tmp/4yj6p1293646134.ps tmp/4yj6p1293646134.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.417 0.870 1.562