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(14.2,13.5,11.9,14.6,15.6,14.1,14.9,14.2,14.6,17.2,15.4,14.3,17.5,14.5,14.4,16.6,16.7,16.6,16.9,15.7,16.4,18.4,16.9,16.5,18.3,15.1,15.7,18.1,16.8,18.9,19,18.1,17.8,21.5,17.1,18.7,19,16.4,16.9,18.6,19.3,19.4,17.6,18.6,18.1,20.4,18.1,19.6,19.9,19.2,17.8,19.2,22,21.1,19.5,22.2,20.9,22.2,23.5,21.5,24.3,22.8,20.3,23.7,23.3,19.6,18,17.3,16.8,18.2,16.5,16,18.4) > 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.3325977 13.50913 -0.641726757 Feb 1 -0.9057133 13.70317 0.702540580 Mar 1 -1.7268289 13.89722 -0.270387495 Apr 1 0.5355348 14.08769 -0.023227526 May 1 0.9812323 14.27817 0.340598705 Jun 1 0.2777411 14.46457 -0.642311221 Jul 1 -0.3924188 14.65097 0.641447436 Aug 1 -0.3919299 14.83208 -0.240146772 Sep 1 -0.6747749 15.01318 0.261592971 Oct 1 1.5283432 15.17651 0.495144105 Nov 1 -0.2185396 15.33984 0.278696088 Dec 1 -0.3452442 15.48984 -0.844594754 Jan 2 1.3325977 15.63983 0.527567873 Feb 2 -0.9057133 15.78041 -0.374699010 Mar 2 -1.7268289 15.92099 0.205838695 Apr 2 0.5355348 16.05826 0.006202472 May 2 0.9812323 16.19554 -0.476767489 Jun 2 0.2777411 16.31953 0.002723960 Jul 2 -0.3924188 16.44353 0.848883992 Aug 2 -0.3919299 16.54127 -0.449344341 Sep 2 -0.6747749 16.63901 0.435761277 Oct 2 1.5283432 16.72081 0.150849019 Nov 2 -0.2185396 16.80260 0.315937611 Dec 2 -0.3452442 16.91897 -0.073724629 Jan 3 1.3325977 17.03534 -0.067933399 Feb 3 -0.9057133 17.19428 -1.188570995 Mar 3 -1.7268289 17.35323 0.073595997 Apr 3 0.5355348 17.52812 0.036348305 May 3 0.9812323 17.70300 -1.884233125 Jun 3 0.2777411 17.85024 0.772018700 Jul 3 -0.3924188 17.99748 1.394939109 Aug 3 -0.3919299 18.10761 0.384322795 Sep 3 -0.6747749 18.21773 0.257040432 Oct 3 1.5283432 18.28366 1.687998597 Nov 3 -0.2185396 18.34958 -1.031042389 Dec 3 -0.3452442 18.36624 0.679006103 Jan 4 1.3325977 18.38289 -0.715491936 Feb 4 -0.9057133 18.37231 -1.066592196 Mar 4 -1.7268289 18.36172 0.265112133 Apr 4 0.5355348 18.38604 -0.321574932 May 4 0.9812323 18.41036 -0.091595735 Jun 4 0.2777411 18.49288 0.629374658 Jul 4 -0.3924188 18.57541 -0.582986367 Aug 4 -0.3919299 18.69071 0.301216933 Sep 4 -0.6747749 18.80602 -0.031245818 Oct 4 1.5283432 18.93186 -0.060207629 Nov 4 -0.2185396 19.05771 -0.739168591 Dec 4 -0.3452442 19.22091 0.724329367 Jan 5 1.3325977 19.38412 -0.816719206 Feb 5 -0.9057133 19.60461 0.501101807 Mar 5 -1.7268289 19.82510 -0.298272593 Apr 5 0.5355348 20.08901 -1.424548604 May 5 0.9812323 20.35293 0.665841646 Jun 5 0.2777411 20.65021 0.172053807 Jul 5 -0.3924188 20.94748 -1.055065448 Aug 5 -0.3919299 21.24785 1.344080829 Sep 5 -0.6747749 21.54821 0.026561055 Oct 5 1.5283432 21.77156 -1.099898658 Nov 5 -0.2185396 21.99490 1.723642478 Dec 5 -0.3452442 21.98957 -0.144324715 Jan 6 1.3325977 21.98424 0.983161561 Feb 6 -0.9057133 21.72027 1.985444527 Mar 6 -1.7268289 21.45630 0.570532082 Apr 6 0.5355348 20.94533 2.219134088 May 6 0.9812323 20.43437 1.884402356 Jun 6 0.2777411 19.87140 -0.549138206 Jul 6 -0.3924188 19.30843 -0.916010184 Aug 6 -0.3919299 18.72525 -1.033321079 Sep 6 -0.6747749 18.14207 -0.667298025 Oct 6 1.5283432 17.53743 -0.865771912 Nov 6 -0.2185396 16.93278 -0.214244950 Dec 6 -0.3452442 16.32232 0.022926248 Jan 7 1.3325977 15.71185 1.355550915 > m$win s t l 731 19 13 > m$deg s t l 0 1 1 > m$jump s t l 74 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1z47o1259922071.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/26ng01259922071.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/3qnfp1259922071.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/405wa1259922071.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/5ca0n1259922071.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/6ccd81259922071.tab") > system("convert tmp/1z47o1259922071.ps tmp/1z47o1259922071.png") > system("convert tmp/26ng01259922071.ps tmp/26ng01259922071.png") > system("convert tmp/3qnfp1259922071.ps tmp/3qnfp1259922071.png") > system("convert tmp/405wa1259922071.ps tmp/405wa1259922071.png") > > > proc.time() user system elapsed 1.008 0.597 1.200