R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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.7,3,2.7,2.5,2.2,2.9,3.1,3,2.8,2.5,1.9,1.9,1.8,2,2.6,2.5,2.5,1.6,1.4,0.8,1.1,1.3,1.2,1.3,1.1,1.3,1.2,1.6,1.7,1.5,0.9,1.5,1.4,1.6,1.7,1.4,1.8,1.7,1.4,1.2,1,1.7,2.4,2,2.1,2,1.8,2.7,2.3,1.9,2,2.3,2.8,2.4,2.3,2.7,2.7,2.9,3,2.2,2.3,2.8,2.8,2.8,2.2,2.6,2.8,2.5,2.4,2.3,1.9,1.7,2,2.1,1.7,1.8,1.8,1.8,1.3,1.3,1.3,1.2,1.4,2.2,2.9,3.1,3.5,3.6,4.4,4.1,5.1,5.8,5.9,5.4,5.5,4.8,3.2,2.7,2.1,1.9,0.6,0.7,-0.2,-1,-1.7,-0.7,-1,-0.9,0,0.3,0.8,0.8,1.9,2.1,2.5,2.7,2.4,2.4,2.9,3.1,3,3.4,3.7,3.5,3.5,3.3,3.1,3.4,4,3.4,3.4,3.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 -0.0168920262 3.12601109 0.590880933 Feb 1 0.0026646209 3.04701642 -0.049681043 Mar 1 0.0222210802 2.96802175 -0.290242830 Apr 1 0.0231982529 2.88735123 -0.410549479 May 1 0.0332661817 2.80668070 -0.639946884 Jun 1 0.0397558279 2.72358796 0.136656214 Jul 1 0.0371546304 2.64049521 0.422350155 Aug 1 0.0324807609 2.56491171 0.402607526 Sep 1 0.0005340501 2.48932821 0.310137737 Oct 1 -0.0165741770 2.44453942 0.072034754 Nov 1 -0.0791370233 2.39975063 -0.420613610 Dec 1 -0.0786721849 2.32248200 -0.343809816 Jan 2 -0.0168920262 2.24521337 -0.428321342 Feb 2 0.0026646209 2.12366026 -0.126324877 Mar 2 0.0222210802 2.00210714 0.575671776 Apr 2 0.0231982529 1.89752963 0.579272117 May 2 0.0332661817 1.79295212 0.673781701 Jun 2 0.0397558279 1.71061242 -0.150368252 Jul 2 0.0371546304 1.62827273 -0.265427360 Aug 2 0.0324807609 1.54162073 -0.774101487 Sep 2 0.0005340501 1.45496872 -0.355502773 Oct 2 -0.0165741770 1.38902511 -0.072450936 Nov 2 -0.0791370233 1.32308150 -0.043944479 Dec 2 -0.0786721849 1.30659773 0.072074454 Jan 3 -0.0168920262 1.29011396 -0.173221934 Feb 3 0.0026646209 1.30685931 -0.009523934 Mar 3 0.0222210802 1.32360467 -0.145825746 Apr 3 0.0231982529 1.34859433 0.228207419 May 3 0.0332661817 1.37358399 0.293149828 Jun 3 0.0397558279 1.40542726 0.054816914 Jul 3 0.0371546304 1.43727053 -0.574425157 Aug 3 0.0324807609 1.46134869 0.006170552 Sep 3 0.0005340501 1.48542685 -0.085960898 Oct 3 -0.0165741770 1.48644259 0.130131591 Nov 3 -0.0791370233 1.48745832 0.291678699 Dec 3 -0.0786721849 1.50397425 -0.025302070 Jan 4 -0.0168920262 1.52049019 0.296401841 Feb 4 0.0026646209 1.56330060 0.134034776 Mar 4 0.0222210802 1.60611102 -0.228332101 Apr 4 0.0231982529 1.65134368 -0.474541934 May 4 0.0332661817 1.69657634 -0.729842523 Jun 4 0.0397558279 1.75336211 -0.093117934 Jul 4 0.0371546304 1.81014787 0.552697499 Aug 4 0.0324807609 1.87753006 0.089989178 Sep 4 0.0005340501 1.94491225 0.154553699 Oct 4 -0.0165741770 2.02070017 -0.004125997 Nov 4 -0.0791370233 2.09648810 -0.217351073 Dec 4 -0.0786721849 2.15460603 0.624066157 Jan 5 -0.0168920262 2.21272396 0.104168067 Feb 5 0.0026646209 2.25812082 -0.360785440 Mar 5 0.0222210802 2.30351768 -0.325738758 Apr 5 0.0231982529 2.35640749 -0.079605741 May 5 0.0332661817 2.40929730 0.357436520 Jun 5 0.0397558279 2.45165209 -0.091407917 Jul 5 0.0371546304 2.49400688 -0.231161510 Aug 5 0.0324807609 2.53291591 0.134603333 Sep 5 0.0005340501 2.57182493 0.127641017 Oct 5 -0.0165741770 2.59635836 0.320215815 Nov 5 -0.0791370233 2.62089179 0.458245231 Dec 5 -0.0786721849 2.62556939 -0.346897206 Jan 6 -0.0168920262 2.63024699 -0.313354963 Feb 6 0.0026646209 2.61677384 0.180561537 Mar 6 0.0222210802 2.60330070 0.174478224 Apr 6 0.0231982529 2.56528436 0.211517387 May 6 0.0332661817 2.52726802 -0.360534207 Jun 6 0.0397558279 2.47509908 0.085145091 Jul 6 0.0371546304 2.42293014 0.339915232 Aug 6 0.0324807609 2.35950123 0.108018013 Sep 6 0.0005340501 2.29607231 0.103393635 Oct 6 -0.0165741770 2.22316733 0.093406844 Nov 6 -0.0791370233 2.15026235 -0.171125327 Dec 6 -0.0786721849 2.06888439 -0.290212204 Jan 7 -0.0168920262 1.98750643 0.029385599 Feb 7 0.0026646209 1.89648848 0.200846895 Mar 7 0.0222210802 1.80547054 -0.127691621 Apr 7 0.0231982529 1.73746874 0.039333010 May 7 0.0332661817 1.66946693 0.097266884 Jun 7 0.0397558279 1.66958935 0.090654823 Jul 7 0.0371546304 1.66971176 -0.406866395 Aug 7 0.0324807609 1.75504913 -0.487529893 Sep 7 0.0005340501 1.84038650 -0.540920551 Oct 7 -0.0165741770 2.01249739 -0.795923216 Nov 7 -0.0791370233 2.18460829 -0.705471263 Dec 7 -0.0786721849 2.44623364 -0.167561455 Jan 8 -0.0168920262 2.70785899 0.209033033 Feb 8 0.0026646209 3.05586685 0.041468527 Mar 8 0.0222210802 3.40387471 0.073904210 Apr 8 0.0231982529 3.75206307 -0.175261319 May 8 0.0332661817 4.10025142 0.266482397 Jun 8 0.0397558279 4.31584070 -0.255596523 Jul 8 0.0371546304 4.53142997 0.531415400 Aug 8 0.0324807609 4.54162220 1.225897040 Sep 8 0.0005340501 4.55181443 1.347651522 Oct 8 -0.0165741770 4.36144192 1.055132254 Nov 8 -0.0791370233 4.17106942 1.408067606 Dec 8 -0.0786721849 3.78731980 1.091352380 Jan 9 -0.0168920262 3.40357019 -0.186678166 Feb 9 0.0026646209 2.85951828 -0.162182898 Mar 9 0.0222210802 2.31546636 -0.237687442 Apr 9 0.0231982529 1.75108385 0.125717901 May 9 0.0332661817 1.18670133 -0.619967512 Jun 9 0.0397558279 0.75509099 -0.094846815 Jul 9 0.0371546304 0.32348064 -0.560635275 Aug 9 0.0324807609 0.09697377 -1.129454530 Sep 9 0.0005340501 -0.12953311 -1.571000944 Oct 9 -0.0165741770 -0.15717266 -0.526253163 Nov 9 -0.0791370233 -0.18481221 -0.736050764 Dec 9 -0.0786721849 -0.02046301 -0.800864810 Jan 10 -0.0168920262 0.14388620 -0.126994176 Feb 10 0.0026646209 0.43663401 -0.139298633 Mar 10 0.0222210802 0.72938182 0.048397097 Apr 10 0.0231982529 1.05306527 -0.276263522 May 10 0.0332661817 1.37674872 0.489985102 Jun 10 0.0397558279 1.67212110 0.388123077 Jul 10 0.0371546304 1.96749347 0.495351895 Aug 10 0.0324807609 2.21715477 0.450364473 Sep 10 0.0005340501 2.46681606 -0.067350108 Oct 10 -0.0165741770 2.65333623 -0.236762048 Nov 10 -0.0791370233 2.83985639 0.139280631 Dec 10 -0.0786721849 2.95518743 0.223484759 Jan 11 -0.0168920262 3.07051846 -0.053626434 Feb 11 0.0026646209 3.15370453 0.243630853 Mar 11 0.0222210802 3.23689059 0.440888327 Apr 11 0.0231982529 3.28634756 0.190454184 May 11 0.0332661817 3.33580453 0.130929284 Jun 11 0.0397558279 3.37805125 -0.117807082 Jul 11 0.0371546304 3.42029797 -0.357452604 Aug 11 0.0324807609 3.45734531 -0.089826072 Sep 11 0.0005340501 3.49439265 0.505073301 Oct 11 -0.0165741770 3.52827441 -0.111700237 Nov 11 -0.0791370233 3.56215618 -0.083019155 Dec 11 -0.0786721849 3.59393272 -0.115260539 > m$win s t l 1321 19 13 > m$deg s t l 0 1 1 > m$jump s t l 133 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/wessaorg/rcomp/tmp/1gx4r1324467918.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/2whr01324467918.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/3aszd1324467918.ps",horizontal=F,onefile=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/wessaorg/rcomp/tmp/43jmn1324467918.ps",horizontal=F,onefile=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/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/5ni021324467918.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/wessaorg/rcomp/tmp/615mc1324467918.tab") > > try(system("convert tmp/1gx4r1324467918.ps tmp/1gx4r1324467918.png",intern=TRUE)) character(0) > try(system("convert tmp/2whr01324467918.ps tmp/2whr01324467918.png",intern=TRUE)) character(0) > try(system("convert tmp/3aszd1324467918.ps tmp/3aszd1324467918.png",intern=TRUE)) character(0) > try(system("convert tmp/43jmn1324467918.ps tmp/43jmn1324467918.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.715 0.270 1.989