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(267413,267366,264777,258863,254844,254868,277267,285351,286602,283042,276687,277915,277128,277103,275037,270150,267140,264993,287259,291186,292300,288186,281477,282656,280190,280408,276836,275216,274352,271311,289802,290726,292300,278506,269826,265861,269034,264176,255198,253353,246057,235372,258556,260993,254663,250643,243422,247105,248541,245039,237080,237085,225554,226839,247934,248333,246969,245098,246263,255765,264319,268347,273046,273963,267430,271993,292710) > 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 2198.5257 264021.8 1192.65744 Feb 1 1149.7802 265264.0 952.23364 Mar 1 -2612.1338 266506.2 882.97837 Apr 1 -5266.6050 267716.2 -3586.54759 May 1 -11239.2430 268926.1 -2842.90685 Jun 1 -13534.0738 270070.4 -1668.35725 Jul 1 7196.6001 271214.7 -1144.31243 Aug 1 10507.3209 272312.4 2531.26299 Sep 1 9645.6054 273410.1 3546.27459 Oct 1 3864.7858 274438.5 4738.67235 Nov 1 -2004.2334 275467.0 3224.26973 Dec 1 93.6705 276182.5 1638.80192 Jan 2 2198.5257 276898.1 -1968.61722 Feb 2 1149.7802 277386.3 -1433.04236 Mar 2 -2612.1338 277874.4 -225.29894 Apr 2 -5266.6050 278332.0 -2915.36399 May 2 -11239.2430 278789.5 -410.26233 Jun 2 -13534.0738 279255.6 -728.52827 Jul 2 7196.6001 279721.7 340.70101 Aug 2 10507.3209 280087.7 591.02521 Sep 2 9645.6054 280453.6 2200.78559 Oct 2 3864.7858 280774.1 3547.14385 Nov 2 -2004.2334 281094.5 2386.70173 Dec 2 93.6705 281368.2 1194.14021 Jan 3 2198.5257 281641.8 -3650.37264 Feb 3 1149.7802 281657.0 -2398.73422 Mar 3 -2612.1338 281672.1 -2223.92726 Apr 3 -5266.6050 281216.9 -734.32284 May 3 -11239.2430 280761.8 4829.44828 Jun 3 -13534.0738 279815.1 5030.01081 Jul 3 7196.6001 278868.3 3737.06856 Aug 3 10507.3209 277359.3 2859.40892 Sep 3 9645.6054 275850.2 6804.18547 Oct 3 3864.7858 273683.2 958.05536 Nov 3 -2004.2334 271516.1 314.12487 Dec 3 93.6705 268855.4 -3088.05997 Jan 4 2198.5257 266194.7 640.80386 Feb 4 1149.7802 263479.1 -452.83267 Mar 4 -2612.1338 260763.4 -2953.30066 Apr 4 -5266.6050 258351.2 268.43960 May 4 -11239.2430 255938.9 1357.34657 Jun 4 -13534.0738 254040.4 -5134.30584 Jul 4 7196.6001 252141.9 -782.46303 Aug 4 10507.3209 250578.8 -93.15927 Sep 4 9645.6054 249015.8 -3998.41933 Oct 4 3864.7858 247676.3 -898.03645 Nov 4 -2004.2334 246336.7 -910.45393 Dec 4 93.6705 245254.5 1756.86347 Jan 5 2198.5257 244172.2 2170.22953 Feb 5 1149.7802 243329.8 559.43630 Mar 5 -2612.1338 242487.3 -2795.18839 Apr 5 -5266.6050 242095.6 256.00353 May 5 -11239.2430 241703.9 -4910.63783 Jun 5 -13534.0738 242277.8 -1904.73110 Jul 5 7196.6001 242851.7 -2114.32916 Aug 5 10507.3209 244810.2 -6984.51160 Sep 5 9645.6054 246768.7 -9445.25785 Oct 5 3864.7858 250319.1 -9085.91534 Nov 5 -2004.2334 253869.6 -5602.37320 Dec 5 93.6705 257978.8 -2307.50658 Jan 6 2198.5257 262088.1 32.40870 Feb 6 1149.7802 266312.1 885.14528 Mar 6 -2612.1338 270536.1 5122.05040 Apr 6 -5266.6050 274907.6 4322.04206 May 6 -11239.2430 279279.0 -609.79956 Jun 6 -13534.0738 283743.3 1783.74572 Jul 6 7196.6001 288207.6 -2694.21379 > m$win s t l 671 19 13 > m$deg s t l 0 1 1 > m$jump s t l 68 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/16gtn1259963760.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/2fwbs1259963760.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/34rrn1259963760.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/4gnpa1259963760.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/5j37s1259963760.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/6t1rf1259963760.tab") > system("convert tmp/16gtn1259963760.ps tmp/16gtn1259963760.png") > system("convert tmp/2fwbs1259963760.ps tmp/2fwbs1259963760.png") > system("convert tmp/34rrn1259963760.ps tmp/34rrn1259963760.png") > system("convert tmp/4gnpa1259963760.ps tmp/4gnpa1259963760.png") > > > proc.time() user system elapsed 0.971 0.602 1.155