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(111.4,87.4,96.8,114.1,110.3,103.9,101.6,94.6,95.9,104.7,102.8,98.1,113.9,80.9,95.7,113.2,105.9,108.8,102.3,99,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102,106,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100,110.7,112.8,109.8,117.3,109.1,115.9,96,99.8,116.8,115.7,99.4,94.3,91,93.2,103.1,94.1,91.8,102.7) > 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 9.16838098 103.66827 -1.43665395 Feb 1 -17.17193236 103.36826 1.20367368 Mar 1 -6.06557350 103.06824 -0.20267087 Apr 1 8.95722356 102.78526 2.35751755 May 1 8.98002436 102.50227 -1.18229776 Jun 1 2.60386790 102.24294 -0.94680526 Jul 1 -4.89229589 101.98360 4.50869456 Aug 1 -4.50979903 101.73644 -2.62663880 Sep 1 -3.02730723 101.48927 -2.56196712 Oct 1 6.01711529 101.29348 -2.61059779 Nov 1 0.08153629 101.09769 1.62077307 Dec 1 -0.14124097 101.19654 -2.95530244 Jan 2 9.16838098 101.29540 3.43622285 Feb 2 -17.17193236 101.64576 -3.57382535 Mar 2 -6.06557350 101.99612 -0.23054576 Apr 2 8.95722356 102.47584 1.76693979 May 2 8.98002436 102.95555 -6.03557840 Jun 2 2.60386790 103.40158 2.79454776 Jul 2 -4.89229589 103.84761 3.34468124 Aug 2 -4.50979903 104.23737 -0.72756965 Sep 2 -3.02730723 104.62712 -0.89981549 Oct 2 6.01711529 104.98178 4.50110445 Nov 2 0.08153629 105.33644 -4.71797408 Dec 2 -0.14124097 105.67088 4.37035885 Jan 3 9.16838098 106.00533 -0.57370743 Feb 3 -17.17193236 106.34770 -3.77576719 Mar 3 -6.06557350 106.69007 -0.12449915 Apr 3 8.95722356 107.04895 -1.20617582 May 3 8.98002436 107.40783 0.11214377 Jun 3 2.60386790 107.73018 2.56595003 Jul 3 -4.89229589 108.05253 -1.16023640 Aug 3 -4.50979903 108.32486 2.18493622 Sep 3 -3.02730723 108.59719 -0.26988611 Oct 3 6.01711529 108.76091 4.02197827 Nov 3 0.08153629 108.92462 -2.90615582 Dec 3 -0.14124097 108.99794 0.44329625 Jan 4 9.16838098 109.07127 -1.03965088 Feb 4 -17.17193236 109.21833 0.45360293 Mar 4 -6.06557350 109.36539 0.90018454 Apr 4 8.95722356 109.57375 -6.03097510 May 4 8.98002436 109.78211 3.63786152 Jun 4 2.60386790 109.97816 0.71797307 Jul 4 -4.89229589 110.17420 -5.28190807 Aug 4 -4.50979903 110.24079 4.96901182 Sep 4 -3.02730723 110.30737 5.51993675 Oct 4 6.01711529 110.11705 -6.33416746 Nov 4 0.08153629 109.92673 7.29172985 Dec 4 -0.14124097 109.20294 0.03830055 Jan 5 9.16838098 108.47915 -1.74752797 Feb 5 -17.17193236 107.27611 5.89581747 Mar 5 -6.06557350 106.07308 -0.20750929 Apr 5 8.95722356 104.60562 3.23715316 May 5 8.98002436 103.13816 3.58181188 Jun 5 2.60386790 101.65643 -4.86029803 Jul 5 -4.89229589 100.17470 -0.98240062 Aug 5 -4.50979903 98.66371 -3.15390685 Sep 5 -3.02730723 97.15272 -0.92540803 Oct 5 6.01711529 95.63205 1.45083033 Nov 5 0.08153629 94.11139 -0.09292979 Dec 5 -0.14124097 92.60472 -0.66348066 Jan 6 9.16838098 91.09805 2.43356925 > m$win s t l 611 19 13 > m$deg s t l 0 1 1 > m$jump s t l 62 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/140ek1259702273.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/242ru1259702273.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/3ta6t1259702273.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/4v6sr1259702273.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/51l3d1259702273.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/60juv1259702273.tab") > system("convert tmp/140ek1259702273.ps tmp/140ek1259702273.png") > system("convert tmp/242ru1259702273.ps tmp/242ru1259702273.png") > system("convert tmp/3ta6t1259702273.ps tmp/3ta6t1259702273.png") > system("convert tmp/4v6sr1259702273.ps tmp/4v6sr1259702273.png") > > > proc.time() user system elapsed 0.968 0.635 1.148