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(3.2,1.9,0,0.6,0.2,0.9,2.4,4.7,9.4,12.5,15.8,18.2,16.8,17.3,19.3,17.9,20.2,18.7,20.1,18.2,18.4,18.2,18.9,19.9,21.3,20,19.5,19.6,20.9,21,19.9,19.6,20.9,21.7,22.9,21.5,21.3,23.5,21.6,24.5,22.2,23.5,20.9,20.7,18.1,17.1,14.8,13.8,15.2,16,17.6,15,15,16.3,19.4,21.3,20.5,21.1,21.6,22.6) > 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 0.95643533 -2.1648370 4.40840166 Feb 1 0.61196032 -0.7899299 2.07796962 Mar 1 -0.05251487 0.5849771 -0.53246223 Apr 1 -0.54924605 2.0087515 -0.85950549 May 1 -0.78597752 3.4325260 -2.44654845 Jun 1 -0.67748490 4.8643848 -3.28689986 Jul 1 -0.48899340 6.2962435 -3.40725014 Aug 1 -0.37528890 7.7170118 -2.64172290 Sep 1 -0.06158394 9.1377801 0.32380387 Oct 1 0.25270214 10.7327457 1.51455213 Nov 1 0.58698826 12.3277114 2.88530036 Dec 1 0.58300385 13.8242790 3.79271713 Jan 2 0.95643533 15.3208467 0.52271802 Feb 2 0.61196032 16.3703344 0.31770524 Mar 2 -0.05251487 17.4198222 1.93269265 Apr 2 -0.54924605 17.9375792 0.51166683 May 2 -0.78597752 18.4553362 2.53064131 Jun 2 -0.67748490 18.6920115 0.68547337 Jul 2 -0.48899340 18.9286868 1.66030656 Aug 2 -0.37528890 19.0626743 -0.48738542 Sep 2 -0.06158394 19.1966618 -0.73507785 Oct 2 0.25270214 19.2812487 -1.33395082 Nov 2 0.58698826 19.3658356 -1.05282381 Dec 2 0.58300385 19.4832561 -0.16625996 Jan 3 0.95643533 19.6006767 0.74288801 Feb 3 0.61196032 19.7837873 -0.39574762 Mar 3 -0.05251487 19.9668979 -0.41438307 Apr 3 -0.54924605 20.1910156 -0.04176951 May 3 -0.78597752 20.4151332 1.27084434 Jun 3 -0.67748490 20.6001514 1.07733353 Jul 3 -0.48899340 20.7851696 -0.39617616 Aug 3 -0.37528890 20.9563776 -0.98108870 Sep 3 -0.06158394 21.1275857 -0.16600171 Oct 3 0.25270214 21.3395040 0.10779383 Nov 3 0.58698826 21.5514224 0.76158935 Dec 3 0.58300385 21.7432311 -0.82623495 Jan 4 0.95643533 21.9350398 -1.59147515 Feb 4 0.61196032 21.9590232 0.92901649 Mar 4 -0.05251487 21.9830066 -0.33049168 Apr 4 -0.54924605 21.6694273 3.37981875 May 4 -0.78597752 21.3558480 1.63012948 Jun 4 -0.67748490 20.7563977 3.42108718 Jul 4 -0.48899340 20.1569474 1.23204600 Aug 4 -0.37528890 19.4582423 1.61704658 Sep 4 -0.06158394 18.7595372 -0.59795329 Oct 4 0.25270214 18.0760066 -1.22870871 Nov 4 0.58698826 17.3924759 -3.17946416 Dec 4 0.58300385 16.9651625 -3.74816638 Jan 5 0.95643533 16.5378492 -2.29428448 Feb 5 0.61196032 16.5795964 -1.19155673 Mar 5 -0.05251487 16.6213437 1.03117121 Apr 5 -0.54924605 17.1902470 -1.64100099 May 5 -0.78597752 17.7591504 -1.97317289 Jun 5 -0.67748490 18.3344413 -1.35695643 Jul 5 -0.48899340 18.9097322 0.97926116 Aug 5 -0.37528890 19.5198876 2.15540129 Sep 5 -0.06158394 20.1300430 0.43154098 Oct 5 0.25270214 20.7683342 0.07896369 Nov 5 0.58698826 21.4066254 -0.39361361 Dec 5 0.58300385 22.0567016 -0.03970541 > 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/1d6di1259947468.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/2ql201259947468.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/3lpj91259947468.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/4n7kn1259947468.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/5jmgv1259947468.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/6kmpz1259947468.tab") > system("convert tmp/1d6di1259947468.ps tmp/1d6di1259947468.png") > system("convert tmp/2ql201259947468.ps tmp/2ql201259947468.png") > system("convert tmp/3lpj91259947468.ps tmp/3lpj91259947468.png") > system("convert tmp/4n7kn1259947468.ps tmp/4n7kn1259947468.png") > > > proc.time() user system elapsed 0.955 0.613 1.157