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(216234,213587,209465,204045,200237,203666,241476,260307,243324,244460,233575,237217,235243,230354,227184,221678,217142,219452,256446,265845,248624,241114,229245,231805,219277,219313,212610,214771,211142,211457,240048,240636,230580,208795,197922,194596,194581,185686,178106,172608,167302,168053,202300,202388,182516,173476,166444,171297,169701,164182,161914,159612,151001,158114,186530,187069,174330,169362,166827,178037,186412,189226,191563,188906,186005,195309,223532,226899,214126) > 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 -1293.7924 213193.7 4334.0639325 Feb 1 -4443.1085 215325.9 2704.2550510 Mar 1 -7993.4250 217458.0 0.4465862 Apr 1 -11166.6316 219559.0 -4347.3698779 May 1 -15934.6735 221660.0 -5488.3509401 Jun 1 -12163.1779 223648.8 -7819.6038423 Jul 1 20118.1533 225637.5 -4279.6922663 Aug 1 25357.0794 227532.7 7417.2117697 Sep 1 10186.6781 229427.9 3709.4433078 Oct 1 3352.9799 231200.5 9906.5166924 Nov 1 -5049.7455 232973.1 5651.6173378 Dec 1 -970.3402 233994.3 4193.0887798 Jan 2 -1293.7924 235015.4 1521.4176945 Feb 2 -4443.1085 235401.6 -604.5081612 Mar 2 -7993.4250 235787.9 -610.4336001 Apr 2 -11166.6316 235732.8 -2888.1266491 May 2 -15934.6735 235677.7 -2600.9842962 Jun 2 -12163.1779 235227.1 -3611.9690254 Jul 2 20118.1533 234776.6 1551.2107236 Aug 2 25357.0794 233962.4 6525.5367467 Sep 2 10186.6781 233148.1 5289.1902718 Oct 2 3352.9799 232212.4 5548.6198792 Nov 2 -5049.7455 231276.7 3018.0767472 Dec 2 -970.3402 230090.3 2685.0880745 Jan 3 -1293.7924 228903.8 -8333.0431255 Feb 3 -4443.1085 227233.2 -3477.1374653 Mar 3 -7993.4250 225562.7 -4959.2313883 Apr 3 -11166.6316 223447.4 2490.2211276 May 3 -15934.6735 221332.2 5744.5090453 Jun 3 -12163.1779 218883.6 4736.5802815 Jul 3 20118.1533 216435.0 3494.8159959 Aug 3 25357.0794 213519.2 1759.7455679 Sep 3 10186.6781 210603.3 9790.0026421 Oct 3 3352.9799 207121.5 -1679.4931565 Nov 3 -5049.7455 203639.7 -667.9616944 Dec 3 -970.3402 200016.5 -4450.1745827 Jan 4 -1293.7924 196393.3 -518.5299983 Feb 4 -4443.1085 193017.0 -2887.8934120 Mar 4 -7993.4250 189640.7 -3541.2564090 Apr 4 -11166.6316 186720.4 -2945.7566790 May 4 -15934.6735 183800.1 -563.4215472 Jun 4 -12163.1779 181544.5 -1328.2873730 Jul 4 20118.1533 179288.8 2893.0112793 Aug 4 25357.0794 177571.5 -540.5687827 Sep 4 10186.6781 175854.1 -3524.8213425 Oct 4 3352.9799 174536.9 -4413.8490057 Nov 4 -5049.7455 173219.6 -1725.8494083 Dec 4 -970.3402 172143.6 123.7641803 Jan 5 -1293.7924 171067.6 -72.7647583 Feb 5 -4443.1085 170195.0 -1569.8608885 Mar 5 -7993.4250 169322.4 585.0433980 Apr 5 -11166.6316 168901.9 1876.6864769 May 5 -15934.6735 168481.5 -1545.8350424 Jun 5 -12163.1779 168943.9 1333.3045628 Jul 5 20118.1533 169406.2 -2994.3913538 Aug 5 25357.0794 171093.7 -9381.7487806 Sep 5 10186.6781 172781.1 -8637.7787052 Oct 5 3352.9799 175503.1 -9494.0961472 Nov 5 -5049.7455 178225.1 -6348.3863286 Dec 5 -970.3402 181628.0 -2620.6620633 Jan 6 -1293.7924 185030.9 2674.9196747 Feb 6 -4443.1085 188311.3 5357.8448809 Mar 6 -7993.4250 191591.7 7964.7705039 Apr 6 -11166.6316 194920.0 5152.5832648 May 6 -15934.6735 198248.4 3691.2314275 Jun 6 -12163.1779 201559.0 5913.1743871 Jul 6 20118.1533 204869.6 -1455.7181751 Aug 6 25357.0794 208069.1 -6527.2234356 Sep 6 10186.6781 211268.7 -7329.4011941 > m$win s t l 691 19 13 > m$deg s t l 0 1 1 > m$jump s t l 70 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/11bga1259790387.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/2vugs1259790387.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/3xz2b1259790387.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/4613y1259790387.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/5rmy51259790387.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/6sgld1259790387.tab") > system("convert tmp/11bga1259790387.ps tmp/11bga1259790387.png") > system("convert tmp/2vugs1259790387.ps tmp/2vugs1259790387.png") > system("convert tmp/3xz2b1259790387.ps tmp/3xz2b1259790387.png") > system("convert tmp/4613y1259790387.ps tmp/4613y1259790387.png") > > > proc.time() user system elapsed 0.987 0.591 1.196