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(161,149,139,135,130,127,122,117,112,113,149,157,157,147,137,132,125,123,117,114,111,112,144,150,149,134,123,116,117,111,105,102,95,93,124,130,124,115,106,105,105,101,95,93,84,87,116,120,117,109,105,107,109,109,108,107,99,103,131,137) > 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 20.647310 137.0564 3.29632803 Feb 1 10.173178 136.5220 2.30478919 Mar 1 1.699046 135.9877 1.31325088 Apr 1 -1.066341 135.5421 0.52425337 May 1 -2.631725 135.0965 -2.46474636 Jun 1 -5.360756 134.7098 -2.34899857 Jul 1 -9.889787 134.3230 -2.43325079 Aug 1 -12.438605 133.9486 -4.51003720 Sep 1 -18.587424 133.5742 -2.98682347 Oct 1 -17.060804 133.3825 -3.32165719 Nov 1 14.265817 133.1907 1.54350843 Dec 1 20.250095 132.9984 3.75147198 Jan 2 20.647310 132.8062 3.54649919 Feb 2 10.173178 132.4926 4.33420064 Mar 2 1.699046 132.1791 3.12190261 Apr 2 -1.066341 131.7330 1.33334982 May 2 -2.631725 131.2869 -3.65520520 Jun 2 -5.360756 130.6484 -2.28765447 Jul 2 -9.889787 130.0099 -3.12010373 Aug 2 -12.438605 129.1955 -2.75693444 Sep 2 -18.587424 128.3812 1.20623497 Oct 2 -17.060804 127.4789 1.58193816 Nov 2 14.265817 126.5765 3.15764068 Dec 2 20.250095 125.5773 4.17265050 Jan 3 20.647310 124.5780 3.77472399 Feb 3 10.173178 123.3149 0.51193086 Mar 3 1.699046 122.0518 -0.75086175 Apr 3 -1.066341 120.4819 -3.41556942 May 3 -2.631725 118.9120 0.71972069 Jun 3 -5.360756 117.2169 -0.85617392 Jul 3 -9.889787 115.5219 -0.63206853 Aug 3 -12.438605 113.9699 0.46869041 Sep 3 -18.587424 112.4180 1.16944947 Oct 3 -17.060804 111.2041 -1.14332432 Nov 3 14.265817 109.9903 -0.25609876 Dec 3 20.250095 109.0519 0.69804990 Jan 4 20.647310 108.1134 -4.76073777 Feb 4 10.173178 107.3645 -2.53765041 Mar 4 1.699046 106.6155 -2.31456252 Apr 4 -1.066341 106.0032 0.06315952 May 4 -2.631725 105.3908 2.24087934 Jun 4 -5.360756 104.8207 1.54006240 Jul 4 -9.889787 104.2505 0.63924547 Aug 4 -12.438605 103.7901 1.64847806 Sep 4 -18.587424 103.3297 -0.74228921 Oct 4 -17.060804 103.2523 0.80849462 Nov 4 14.265817 103.1749 -1.44072221 Dec 4 20.250095 103.7537 -4.00383495 Jan 5 20.647310 104.3326 -7.97988403 Feb 5 10.173178 105.5335 -6.70668503 Mar 5 1.699046 106.7344 -3.43348551 Apr 5 -1.066341 108.3859 -0.31954136 May 5 -2.631725 110.0373 1.59440057 Jun 5 -5.360756 111.6409 2.71985635 Jul 5 -9.889787 113.2445 4.64531212 Aug 5 -12.438605 114.9125 4.52613107 Sep 5 -18.587424 116.5805 1.00695015 Oct 5 -17.060804 118.2566 1.80417574 Nov 5 14.265817 119.9328 -3.19859934 Dec 5 20.250095 121.5764 -4.82648321 > 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/1o1md1259697609.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/2ss221259697609.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/39f6s1259697609.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/42rgc1259697609.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/5xoh91259697609.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/6ly941259697609.tab") > system("convert tmp/1o1md1259697609.ps tmp/1o1md1259697609.png") > system("convert tmp/2ss221259697609.ps tmp/2ss221259697609.png") > system("convert tmp/39f6s1259697609.ps tmp/39f6s1259697609.png") > system("convert tmp/42rgc1259697609.ps tmp/42rgc1259697609.png") > > > proc.time() user system elapsed 0.953 0.625 1.339