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(8.3,8.2,8,7.9,7.6,7.6,8.3,8.4,8.4,8.4,8.4,8.6,8.9,8.8,8.3,7.5,7.2,7.4,8.8,9.3,9.3,8.7,8.2,8.3,8.5,8.6,8.5,8.2,8.1,7.9,8.6,8.7,8.7,8.5,8.4,8.5,8.7,8.7,8.6,8.5,8.3,8,8.2,8.1,8.1,8,7.9,7.9,8,8,7.9,8,7.7,7.2,7.5,7.3,7,7,7,7.2,7.3,7.1,6.8,6.4,6.1,6.5,7.7,7.9,7.5,6.9,6.6,6.9) > 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.277639294 7.940665 0.081696160 Feb 1 0.234155554 7.980814 -0.014969257 Mar 1 0.024005110 8.020963 -0.044967970 Apr 1 -0.232841275 8.061151 0.071690415 May 1 -0.473020941 8.101339 -0.028317918 Jun 1 -0.527791762 8.140191 -0.012399464 Jul 1 0.234104089 8.179044 -0.113147681 Aug 1 0.346806920 8.214565 -0.161371639 Sep 1 0.242843237 8.250086 -0.092929082 Oct 1 0.006036023 8.266372 0.127591940 Nov 1 -0.147437911 8.282658 0.264779682 Dec 1 0.015501563 8.282885 0.301613910 Jan 2 0.277639294 8.283111 0.339249881 Feb 2 0.234155554 8.308286 0.257557997 Mar 2 0.024005110 8.333462 -0.057467184 Apr 2 -0.232841275 8.355430 -0.622588803 May 2 -0.473020941 8.377398 -0.704377141 Jun 2 -0.527791762 8.378337 -0.450544902 Jul 2 0.234104089 8.379275 0.186620664 Aug 2 0.346806920 8.390757 0.562435752 Sep 2 0.242843237 8.402239 0.654917354 Oct 2 0.006036023 8.434444 0.259519583 Nov 2 -0.147437911 8.466649 -0.119211470 Dec 2 0.015501563 8.476514 -0.192015938 Jan 3 0.277639294 8.486379 -0.264018664 Feb 3 0.234155554 8.463350 -0.097505828 Mar 3 0.024005110 8.440321 0.035673712 Apr 3 -0.232841275 8.430007 0.002834232 May 3 -0.473020941 8.419693 0.153328033 Jun 3 -0.527791762 8.430148 -0.002356562 Jul 3 0.234104089 8.440604 -0.074707830 Aug 3 0.346806920 8.451785 -0.098591576 Sep 3 0.242843237 8.462966 -0.005808810 Oct 3 0.006036023 8.476447 0.017516665 Nov 3 -0.147437911 8.489929 0.057508859 Dec 3 0.015501563 8.491720 -0.007221355 Jan 4 0.277639294 8.493511 -0.071149827 Feb 4 0.234155554 8.464346 0.001498450 Mar 4 0.024005110 8.435181 0.140813431 Apr 4 -0.232841275 8.385660 0.347180986 May 4 -0.473020941 8.336139 0.436881822 Jun 4 -0.527791762 8.277320 0.250472092 Jul 4 0.234104089 8.218500 -0.252604310 Aug 4 0.346806920 8.153562 -0.400368870 Sep 4 0.242843237 8.088624 -0.231466916 Oct 4 0.006036023 8.034548 -0.040583589 Nov 4 -0.147437911 7.980471 0.066966457 Dec 4 0.015501563 7.936138 -0.051639669 Jan 5 0.277639294 7.891805 -0.169444053 Feb 5 0.234155554 7.831401 -0.065556680 Mar 5 0.024005110 7.770997 0.104997397 Apr 5 -0.232841275 7.690378 0.542463743 May 5 -0.473020941 7.609758 0.563263370 Jun 5 -0.527791762 7.528092 0.199699933 Jul 5 0.234104089 7.446426 -0.180530175 Aug 5 0.346806920 7.355020 -0.401826459 Sep 5 0.242843237 7.263613 -0.506456229 Oct 5 0.006036023 7.163957 -0.169993490 Nov 5 -0.147437911 7.064302 0.083135969 Dec 5 0.015501563 7.014331 0.170167625 Jan 6 0.277639294 6.964360 0.058001022 Feb 6 0.234155554 6.974224 -0.108379278 Mar 6 0.024005110 6.984088 -0.208092874 Apr 6 -0.232841275 6.993179 -0.360338185 May 6 -0.473020941 7.002271 -0.429250215 Jun 6 -0.527791762 7.003274 0.024517470 Jul 6 0.234104089 7.004277 0.461618482 Aug 6 0.346806920 7.009600 0.543593141 Sep 6 0.242843237 7.014922 0.242234314 Oct 6 0.006036023 7.022261 -0.128297166 Nov 6 -0.147437911 7.029600 -0.282161927 Dec 6 0.015501563 7.035861 -0.151362149 > m$win s t l 721 19 13 > m$deg s t l 0 1 1 > m$jump s t l 73 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1t6ei1260547035.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/2cdba1260547035.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/3ouc21260547035.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/4umsi1260547035.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/50elm1260547035.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/6dyhz1260547035.tab") > system("convert tmp/1t6ei1260547035.ps tmp/1t6ei1260547035.png") > system("convert tmp/2cdba1260547035.ps tmp/2cdba1260547035.png") > system("convert tmp/3ouc21260547035.ps tmp/3ouc21260547035.png") > system("convert tmp/4umsi1260547035.ps tmp/4umsi1260547035.png") > > > proc.time() user system elapsed 0.983 0.591 1.169