R version 2.12.0 (2010-10-15) Copyright (C) 2010 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(101.5,100.7,110.6,96.8,100,104.8,86.8,92,100.2,106.6,102.1,93.7,97.6,96.9,105.6,102.8,101.7,104.2,92.7,91.9,106.5,112.3,102.8,96.5,101,98.9,105.1,103,99,104.3,94.6,90.4,108.9,111.4,100.8,102.5,98.2,98.7,113.3,104.6,99.3,111.8,97.3,97.7,115.6,111.9,107,107.1,100.6,99.2,108.4,103,99.8,115,90.8,95.9,114.4,108.2,112.6,109.1,105,105,118.5,103.7,112.5,116.6,96.6,101.9,116.5,119.3,115.4,108.5,111.5,108.8,121.8,109.6,112.2,119.6,104.1,105.3,115,124.1,116.8,107.5,115.6,116.2,116.3,119,111.9,118.6,106.9,103.2,118.6,118.7,102.8,100.6,94.9,94.5,102.9,95.3,92.5,102.7,91.5,89.5,104.2,105.2,99,95.5,90.5,96.1,113,101.9,101.4,113.6,96.6,97.8,114.9,112.5,108.4,107,103.5,107.5,122.3) > 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 -3.3630559 102.51905 2.344003e+00 Feb 1 -3.2235376 102.00981 1.913731e+00 Mar 1 7.1614357 101.50056 1.938005e+00 Apr 1 -0.8368153 101.05490 -3.418089e+00 May 1 -1.8208866 100.60925 1.211638e+00 Jun 1 6.2265718 100.21232 -1.638893e+00 Jul 1 -9.1459717 99.81539 -3.869422e+00 Aug 1 -8.4223968 99.44851 9.738907e-01 Sep 1 6.4511793 99.08162 -5.332798e+00 Oct 1 7.9104471 99.02053 -3.309770e-01 Nov 1 1.5797168 98.95944 1.560842e+00 Dec 1 -2.5166866 99.21661 -2.999922e+00 Jan 2 -3.3630559 99.47378 1.489279e+00 Feb 2 -3.2235376 99.78710 3.364384e-01 Mar 2 7.1614357 100.10042 -1.661857e+00 Apr 2 -0.8368153 100.39237 3.244443e+00 May 2 -1.8208866 100.68432 2.836563e+00 Jun 2 6.2265718 100.89860 -2.925174e+00 Jul 2 -9.1459717 101.11288 7.330915e-01 Aug 2 -8.4223968 101.21192 -8.895202e-01 Sep 2 6.4511793 101.31095 -1.262133e+00 Oct 2 7.9104471 101.31585 3.073701e+00 Nov 2 1.5797168 101.32075 -1.004676e-01 Dec 2 -2.5166866 101.30411 -2.287426e+00 Jan 3 -3.3630559 101.28747 3.075582e+00 Feb 3 -3.2235376 101.28475 8.387859e-01 Mar 3 7.1614357 101.28203 -3.343465e+00 Apr 3 -0.8368153 101.28367 2.553150e+00 May 3 -1.8208866 101.28530 -4.644142e-01 Jun 3 6.2265718 101.34660 -3.273175e+00 Jul 3 -9.1459717 101.40791 2.338066e+00 Aug 3 -8.4223968 101.57549 -2.753095e+00 Sep 3 6.4511793 101.74308 7.057427e-01 Oct 3 7.9104471 102.02027 1.469281e+00 Nov 3 1.5797168 102.29747 -3.077182e+00 Dec 3 -2.5166866 102.65030 2.366382e+00 Jan 4 -3.3630559 103.00314 -1.440089e+00 Feb 4 -3.2235376 103.42145 -1.497911e+00 Mar 4 7.1614357 103.83975 2.298812e+00 Apr 4 -0.8368153 104.24496 1.191859e+00 May 4 -1.8208866 104.65016 -3.529274e+00 Jun 4 6.2265718 104.95721 6.162218e-01 Jul 4 -9.1459717 105.26425 1.181719e+00 Aug 4 -8.4223968 105.32553 7.968636e-01 Sep 4 6.4511793 105.38681 3.762007e+00 Oct 4 7.9104471 105.27134 -1.281784e+00 Nov 4 1.5797168 105.15586 2.644239e-01 Dec 4 -2.5166866 104.97678 4.639907e+00 Jan 5 -3.3630559 104.79770 -8.346438e-01 Feb 5 -3.2235376 104.58171 -2.158177e+00 Mar 5 7.1614357 104.36573 -3.127165e+00 Apr 5 -0.8368153 104.32083 -4.840133e-01 May 5 -1.8208866 104.27593 -2.655041e+00 Jun 5 6.2265718 104.56754 4.205884e+00 Jul 5 -9.1459717 104.85916 -4.913189e+00 Aug 5 -8.4223968 105.39145 -1.069053e+00 Sep 5 6.4511793 105.92374 2.025083e+00 Oct 5 7.9104471 106.50712 -6.217569e+00 Nov 5 1.5797168 107.09051 3.929777e+00 Dec 5 -2.5166866 107.59962 4.017067e+00 Jan 6 -3.3630559 108.10873 2.543235e-01 Feb 6 -3.2235376 108.53632 -3.127867e-01 Mar 6 7.1614357 108.96392 2.374648e+00 Apr 6 -0.8368153 109.29510 -4.758285e+00 May 6 -1.8208866 109.62628 4.694603e+00 Jun 6 6.2265718 109.92483 4.485966e-01 Jul 6 -9.1459717 110.22338 -4.477408e+00 Aug 6 -8.4223968 110.56956 -2.471612e-01 Sep 6 6.4511793 110.91574 -8.669159e-01 Oct 6 7.9104471 111.25163 1.379270e-01 Nov 6 1.5797168 111.58752 2.232768e+00 Dec 6 -2.5166866 111.90893 -8.922474e-01 Jan 7 -3.3630559 112.23035 2.632703e+00 Feb 7 -3.2235376 112.47758 -4.540431e-01 Mar 7 7.1614357 112.72481 1.913756e+00 Apr 7 -0.8368153 112.84392 -2.407105e+00 May 7 -1.8208866 112.96303 1.057856e+00 Jun 7 6.2265718 113.10447 2.689569e-01 Jul 7 -9.1459717 113.24591 6.012243e-05 Aug 7 -8.4223968 113.46672 2.556730e-01 Sep 7 6.4511793 113.68754 -5.138715e+00 Oct 7 7.9104471 113.91424 2.275309e+00 Nov 7 1.5797168 114.14095 1.079332e+00 Dec 7 -2.5166866 114.28964 -4.272957e+00 Jan 8 -3.3630559 114.43834 4.524720e+00 Feb 8 -3.2235376 114.45094 4.972602e+00 Mar 8 7.1614357 114.46353 -5.324971e+00 Apr 8 -0.8368153 114.05428 5.782538e+00 May 8 -1.8208866 113.64502 7.586596e-02 Jun 8 6.2265718 112.60477 -2.313429e-01 Jul 8 -9.1459717 111.56452 4.481450e+00 Aug 8 -8.4223968 110.02855 1.593842e+00 Sep 8 6.4511793 108.49259 3.656234e+00 Oct 8 7.9104471 106.77898 4.010573e+00 Nov 8 1.5797168 105.06537 -3.845089e+00 Dec 8 -2.5166866 103.46913 -3.524436e-01 Jan 9 -3.3630559 101.87289 -3.609832e+00 Feb 9 -3.2235376 100.62834 -2.904807e+00 Mar 9 7.1614357 99.38380 -3.645237e+00 Apr 9 -0.8368153 98.62475 -2.487937e+00 May 9 -1.8208866 97.86570 -3.544817e+00 Jun 9 6.2265718 97.57477 -1.101344e+00 Jul 9 -9.1459717 97.28384 3.362130e+00 Aug 9 -8.4223968 97.45589 4.665037e-01 Sep 9 6.4511793 97.62794 1.208758e-01 Oct 9 7.9104471 98.15857 -8.690187e-01 Nov 9 1.5797168 98.68920 -1.268915e+00 Dec 9 -2.5166866 99.38489 -1.368205e+00 Jan 10 -3.3630559 100.08059 -6.217530e+00 Feb 10 -3.2235376 100.85706 -1.533518e+00 Mar 10 7.1614357 101.63352 4.205040e+00 Apr 10 -0.8368153 102.51128 2.255392e-01 May 10 -1.8208866 103.38903 -1.681408e-01 Jun 10 6.2265718 104.21021 3.163221e+00 Jul 10 -9.1459717 105.03139 7.145848e-01 Aug 10 -8.4223968 105.88042 3.419724e-01 Sep 10 6.4511793 106.72946 1.719359e+00 Oct 10 7.9104471 107.57288 -2.983324e+00 Nov 10 1.5797168 108.41629 -1.596009e+00 Dec 10 -2.5166866 109.23062 2.860693e-01 Jan 11 -3.3630559 110.04494 -3.181886e+00 Feb 11 -3.2235376 110.84858 -1.250399e-01 Mar 11 7.1614357 111.65221 3.486351e+00 > m$win s t l 1231 19 13 > m$deg s t l 0 1 1 > m$jump s t l 124 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/rcomp/tmp/1c0vy1322764677.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/www/rcomp/tmp/2kyt51322764677.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/www/rcomp/tmp/3835i1322764677.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/www/rcomp/tmp/46l701322764677.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/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/5eqkc1322764677.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/rcomp/tmp/654my1322764677.tab") > > try(system("convert tmp/1c0vy1322764677.ps tmp/1c0vy1322764677.png",intern=TRUE)) character(0) > try(system("convert tmp/2kyt51322764677.ps tmp/2kyt51322764677.png",intern=TRUE)) character(0) > try(system("convert tmp/3835i1322764677.ps tmp/3835i1322764677.png",intern=TRUE)) character(0) > try(system("convert tmp/46l701322764677.ps tmp/46l701322764677.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.770 0.080 1.844