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(100,96.21064363,96.31280765,107.1793443,114.9066592,92.56060184,114.9995356,107.1236185,117.7765394,107.3650971,106.2970187,114.5072908,98.0031578,103.0649206,100.2879168,104.6066685,111.1544534,104.9874617,109.9284852,111.5352466,132.4974459,100.3436426,123.0983561,114.2379493,104.569518,109.0833101,106.9843039,133.6769759,124.8537197,122.5132349,116.8013374,116.0118882,129.7575926,125.1973623,143.7912139,127.9465032,130.2962757,108.4424631,129.3675118,143.6797622,131.8844618,117.6186496,118.9560695,104.8202842,134.624315,140.401226,143.8005015,153.4317823,153.2924677,127.3149438,153.5525216,136.9276493,131.7730101,144.3391845,107.4208229,113.6249652,124.2221603,102.0618557,96.36853348,111.6838488) > 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.228273 103.0408 -1.81253672 Feb 1 -9.839254 103.6300 2.41994241 Mar 1 -1.563463 104.2191 -6.34282993 Apr 1 6.517436 104.7001 -4.03823332 May 1 4.385634 105.1812 5.33984301 Jun 1 -2.145831 105.5620 -10.85558093 Jul 1 -4.949233 105.9428 14.00592447 Aug 1 -7.966585 106.3169 8.77326295 Sep 1 9.166529 106.6910 1.91897367 Oct 1 -3.363486 106.8512 3.87736637 Nov 1 4.405566 107.0114 -5.11994510 Dec 1 6.580950 106.9106 1.01574481 Jan 2 -1.228273 106.8098 -7.57836446 Feb 2 -9.839254 107.0975 5.80670043 Mar 2 -1.563463 107.3852 -5.53377314 Apr 2 6.517436 108.0670 -9.97772439 May 2 4.385634 108.7488 -1.97994097 Jun 2 -2.145831 109.4359 -2.30260162 Jul 2 -4.949233 110.1230 4.75469114 Aug 2 -7.966585 110.8914 8.61043672 Sep 2 9.166529 111.6598 11.67115445 Oct 2 -3.363486 112.7085 -9.00133470 Nov 2 4.405566 113.7572 4.93562489 Dec 2 6.580950 114.6873 -7.03025116 Jan 3 -1.228273 115.6173 -9.81954578 Feb 3 -9.839254 116.4034 2.51915333 Mar 3 -1.563463 117.1895 -8.64171773 Apr 3 6.517436 118.4716 8.68790994 May 3 4.385634 119.7538 0.71431088 Jun 3 -2.145831 121.2612 3.39789682 Jul 3 -4.949233 122.7686 -1.01799173 Aug 3 -7.966585 123.9352 0.04331232 Sep 3 9.166529 125.1018 -4.51069579 Oct 3 -3.363486 125.8468 2.71404210 Nov 3 4.405566 126.5919 12.79379382 Dec 3 6.580950 126.8241 -5.45851935 Jan 4 -1.228273 127.0563 4.46825661 Feb 4 -9.839254 126.9346 -8.65285402 Mar 4 -1.563463 126.8128 4.11812478 Apr 4 6.517436 127.1326 10.02973435 May 4 4.385634 127.4523 0.04649458 Jun 4 -2.145831 128.6765 -8.91204076 Jul 4 -4.949233 129.9007 -5.99540578 Aug 4 -7.966585 131.5514 -18.76456092 Sep 4 9.166529 133.2022 -7.74436572 Oct 4 -3.363486 134.4993 9.26542328 Nov 4 4.405566 135.7964 3.59850872 Dec 4 6.580950 136.6012 10.24965326 Jan 5 -1.228273 137.4059 17.11480833 Feb 5 -9.839254 136.8835 0.27071842 Mar 5 -1.563463 136.3610 18.75495834 Apr 5 6.517436 132.7490 -2.33876763 May 5 4.385634 129.1369 -1.74955903 Jun 5 -2.145831 125.3834 21.10164164 Jul 5 -4.949233 121.6298 -9.25975547 Aug 5 -7.966585 117.6862 3.90532898 Sep 5 9.166529 113.7426 1.31300047 Oct 5 -3.363486 109.5835 -4.15812550 Nov 5 4.405566 105.4243 -13.46133716 Dec 5 6.580950 101.1164 3.98653533 > 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/13d8s1259944460.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/2kwoc1259944460.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/3cmyo1259944460.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/4ih581259944460.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/5ohwf1259944460.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/6e2n81259944460.tab") > > system("convert tmp/13d8s1259944460.ps tmp/13d8s1259944460.png") > system("convert tmp/2kwoc1259944460.ps tmp/2kwoc1259944460.png") > system("convert tmp/3cmyo1259944460.ps tmp/3cmyo1259944460.png") > system("convert tmp/4ih581259944460.ps tmp/4ih581259944460.png") > > > proc.time() user system elapsed 0.972 0.644 1.163