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(96.96,93.11,95.62,98.30,96.38,100.82,99.06,94.03,102.07,99.31,98.64,101.82,99.14,97.63,100.06,101.32,101.49,105.43,105.09,99.48,108.53,104.34,106.10,107.35,103.00,104.50,105.17,104.84,106.18,108.86,107.77,102.74,112.63,106.26,108.86,111.38,106.85,107.86,107.94,111.38,111.29,113.72,111.88,109.87,113.72,111.71,114.81,112.05,111.54,110.87,110.87,115.48,111.63,116.24,113.56,106.01,110.45,107.77,108.61,108.19) > 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 -1.5322816 96.59047 1.9018114 Feb 1 -2.4806779 96.84620 -1.2555223 Mar 1 -1.5870759 97.10193 0.1051457 Apr 1 0.5989011 97.36784 0.3332580 May 1 -0.4171186 97.63375 -0.8366329 Jun 1 3.0713496 97.90621 -0.1575576 Jul 1 1.3978192 98.17866 -0.5164837 Aug 1 -3.7767872 98.46093 -0.6541399 Sep 1 3.1486064 98.74319 0.1782038 Oct 1 -0.6015429 99.08955 0.8219950 Nov 1 0.7763101 99.43591 -1.5722162 Dec 1 1.4024966 99.84717 0.5703319 Jan 2 -1.5322816 100.25844 0.4138446 Feb 2 -2.4806779 100.72544 -0.6147583 Mar 2 -1.5870759 101.19244 0.4546405 Apr 2 0.5989011 101.69376 -0.9726586 May 2 -0.4171186 102.19508 -0.2879608 Jun 2 3.0713496 102.68964 -0.3309924 Jul 2 1.3978192 103.18421 0.5079746 Aug 2 -3.7767872 103.64303 -0.3862456 Sep 2 3.1486064 104.10186 1.2795342 Oct 2 -0.6015429 104.48627 0.4552757 Nov 2 0.7763101 104.87068 0.4530148 Dec 2 1.4024966 105.15534 0.7921620 Jan 3 -1.5322816 105.44001 -0.9077262 Feb 3 -2.4806779 105.67572 1.3049561 Mar 3 -1.5870759 105.91144 0.8456400 Apr 3 0.5989011 106.14888 -1.9077849 May 3 -0.4171186 106.38633 0.2107870 Jun 3 3.0713496 106.66497 -0.8763236 Jul 3 1.3978192 106.94362 -0.5714356 Aug 3 -3.7767872 107.27754 -0.7607482 Sep 3 3.1486064 107.61145 1.8699391 Oct 3 -0.6015429 108.01727 -1.1557275 Nov 3 0.7763101 108.42309 -0.3393963 Dec 3 1.4024966 108.84274 1.1347603 Jan 4 -1.5322816 109.26240 -0.8801183 Feb 4 -2.4806779 109.64779 0.6928894 Mar 4 -1.5870759 110.03318 -0.5061012 Apr 4 0.5989011 110.38355 0.3975491 May 4 -0.4171186 110.73392 0.9731962 Jun 4 3.0713496 111.03937 -0.3907174 Jul 4 1.3978192 111.34481 -0.8626324 Aug 4 -3.7767872 111.60796 2.0388254 Sep 4 3.1486064 111.87111 -1.2997168 Oct 4 -0.6015429 112.09109 0.2204536 Nov 4 0.7763101 112.31107 1.7226217 Dec 4 1.4024966 112.43160 -1.7841015 Jan 5 -1.5322816 112.55214 0.5201400 Feb 5 -2.4806779 112.44872 0.9019586 Mar 5 -1.5870759 112.34530 0.1117789 Apr 5 0.5989011 111.86821 3.0128843 May 5 -0.4171186 111.39113 0.6559864 Jun 5 3.0713496 110.90455 2.2641027 Jul 5 1.3978192 110.41796 1.7442176 Aug 5 -3.7767872 109.90170 -0.1149088 Sep 5 3.1486064 109.38543 -2.0840351 Oct 5 -0.6015429 108.82373 -0.4521865 Nov 5 0.7763101 108.26203 -0.4283401 Dec 5 1.4024966 107.66824 -0.8807352 > 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/1yjpy1259860842.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/2071n1259860842.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/3abyq1259860842.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/4wjuw1259860842.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/5ab4z1259860842.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/6k1y61259860842.tab") > system("convert tmp/1yjpy1259860842.ps tmp/1yjpy1259860842.png") > system("convert tmp/2071n1259860842.ps tmp/2071n1259860842.png") > system("convert tmp/3abyq1259860842.ps tmp/3abyq1259860842.png") > system("convert tmp/4wjuw1259860842.ps tmp/4wjuw1259860842.png") > > > proc.time() user system elapsed 0.957 0.623 1.132