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(115.6,111.9,107,107.1,100.6,99.2,108.4,103,99.8,115,90.8,95.9,114.4,108.2,112.6,109.1,105,105,118.5,103.7,112.5,116.6,96.6,101.9,116.5,119.3,115.4,108.5,111.5,108.8,121.8,109.6,112.2,119.6,104.1,105.3,115,124.1,116.8,107.5,115.6,116.2,116.3,119,111.9,118.6,106.9,103.2,118.6,118.7,102.8,100.6,94.9,94.5,102.9,95.3,92.5,102.7,91.5,89.5) > 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.150981 105.79790 2.65111893 Feb 1 7.720138 105.58692 -1.40705448 Mar 1 2.349297 105.37593 -0.72522987 Apr 1 -1.952780 105.20312 3.84965501 May 1 -2.934849 105.03032 -1.49546752 Jun 1 -3.628192 104.89497 -2.06678178 Jul 1 5.298466 104.75963 -1.65809676 Aug 1 -1.946571 104.65659 0.28997891 Sep 1 -2.071605 104.55355 -2.68194927 Oct 1 6.969894 104.69779 3.33231376 Nov 1 -9.228603 104.84203 -4.81342757 Dec 1 -7.726174 105.34494 -1.71876547 Jan 2 7.150981 105.84785 1.40117035 Feb 2 7.720138 106.44385 -5.96398793 Mar 2 2.349297 107.03985 3.21085180 Apr 2 -1.952780 107.58890 3.46387946 May 2 -2.934849 108.13795 -0.20310030 Jun 2 -3.628192 108.58175 0.04643660 Jul 2 5.298466 109.02556 4.17597277 Aug 2 -1.946571 109.35219 -3.70562346 Sep 2 -2.071605 109.67883 4.89277646 Oct 2 6.969894 109.94254 -0.31243255 Nov 2 -9.228603 110.20625 -4.37764592 Dec 2 -7.726174 110.52305 -0.89687392 Jan 3 7.150981 110.83985 -1.49082819 Feb 3 7.720138 111.18835 0.39150849 Mar 3 2.349297 111.53686 1.51384319 Apr 3 -1.952780 111.89821 -1.44543502 May 3 -2.934849 112.25957 2.17527934 Jun 3 -3.628192 112.52301 -0.09481992 Jul 3 5.298466 112.78645 3.71508010 Aug 3 -1.946571 112.90101 -1.35444326 Sep 3 -2.071605 113.01558 1.25602954 Oct 3 6.969894 113.12218 -0.49207214 Nov 3 -9.228603 113.22878 0.09982183 Dec 3 -7.726174 113.42021 -0.39403973 Jan 4 7.150981 113.61165 -5.76262756 Feb 4 7.720138 113.85097 2.52889062 Mar 4 2.349297 114.09030 0.36040682 Apr 4 -1.952780 114.27892 -4.82614505 May 4 -2.934849 114.46755 4.06729566 Jun 4 -3.628192 114.49637 5.33182513 Jul 4 5.298466 114.52518 -3.52364614 Aug 4 -1.946571 114.11137 6.83519883 Sep 4 -2.071605 113.69757 0.27403997 Oct 4 6.969894 112.62248 -0.99237193 Nov 4 -9.228603 111.54739 4.58121183 Dec 4 -7.726174 109.98204 0.94412977 Jan 5 7.150981 108.41670 3.03232144 Feb 5 7.720138 106.71571 4.26415459 Mar 5 2.349297 105.01472 -4.56401426 Apr 5 -1.952780 103.68156 -1.12877642 May 5 -2.934849 102.34839 -4.51354601 Jun 5 -3.628192 101.09685 -2.96865749 Jul 5 5.298466 99.84530 -2.24376971 Aug 5 -1.946571 98.62144 -1.37486423 Sep 5 -2.071605 97.39757 -2.82596259 Oct 5 6.969894 96.24113 -0.51102027 Nov 5 -9.228603 95.08468 5.64391770 Dec 5 -7.726174 93.99980 3.22637874 > 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/1zz561259859891.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/2w09m1259859891.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/3yax01259859891.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/450q81259859891.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/56g8f1259859891.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/6klvh1259859891.tab") > > system("convert tmp/1zz561259859891.ps tmp/1zz561259859891.png") > system("convert tmp/2w09m1259859891.ps tmp/2w09m1259859891.png") > system("convert tmp/3yax01259859891.ps tmp/3yax01259859891.png") > system("convert tmp/450q81259859891.ps tmp/450q81259859891.png") > > > proc.time() user system elapsed 0.953 0.611 1.597