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(24,29,29,25,16,18,13,22,15,20,19,18,13,17,17,13,14,13,17,17,15,9,10,9,14,18,18,12,16,12,19,13,12,13,11,10,16,12,6,8,6,8,8,9,13,8,11,8,10,15,12,13,12,15,13,13,16,14,12,15,14,19,16,16,11,13,12,11,6,9,6,15,17,13,12,13,10,14,13,10,11,12,7,11,9,13,12,5,13,11,8,8,8,8,0,3,0,-1,-1,-4,1,-1,0,-1,6,0,-3,-3,4,1,0,-4,-2,3,2,5,6,6,3,4,7,5,6,1,3,6,0,3,4,7,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.8403693 25.107283615 -1.94765292 Feb 1 2.2055590 24.224247000 2.57019398 Mar 1 1.1162015 23.341210384 4.54258815 Apr 1 -1.3816511 22.512172199 3.86947886 May 1 -1.0613234 21.683134014 -4.62181061 Jun 1 0.1505911 20.874615431 -3.02520655 Jul 1 -0.3647653 20.066096848 -6.70133150 Aug 1 0.2281005 19.210652459 2.56124709 Sep 1 0.5482439 18.355208070 -3.90345200 Oct 1 0.1598676 17.639822339 2.20031001 Nov 1 -1.8648721 16.924436609 3.94043549 Dec 1 -0.5763206 16.636943438 1.93937712 Jan 2 0.8403693 16.349450267 -4.18981957 Feb 2 2.2055590 16.070233696 -1.27579272 Mar 2 1.1162015 15.791017126 0.09278141 Apr 2 -1.3816511 15.328547118 -0.94689606 May 2 -1.0613234 14.866077111 0.19524629 Jun 2 0.1505911 14.442172402 -1.59276352 Jul 2 -0.3647653 14.018267692 3.34649765 Aug 2 0.2281005 13.884827988 2.88707156 Sep 2 0.5482439 13.751388283 0.70036779 Oct 2 0.1598676 13.737645648 -4.89751330 Nov 2 -1.8648721 13.723903014 -1.85903092 Dec 2 -0.5763206 13.755158397 -4.17883784 Jan 3 0.8403693 13.786413781 -0.62678308 Feb 3 2.2055590 13.831709370 1.96273161 Mar 3 1.1162015 13.877004960 3.00679358 Apr 3 -1.3816511 13.970679787 -0.58902873 May 3 -1.0613234 14.064354613 2.99696879 Jun 3 0.1505911 14.024624515 -2.17521563 Jul 3 -0.3647653 13.984894416 5.37987093 Aug 3 0.2281005 13.601278960 -0.82937941 Sep 3 0.5482439 13.217663504 -1.76590743 Oct 3 0.1598676 12.599629908 0.24050244 Nov 3 -1.8648721 11.981596312 0.88327578 Dec 3 -0.5763206 11.355478989 -0.77915843 Jan 4 0.8403693 10.729361666 4.43026903 Feb 4 2.2055590 10.289311650 -0.49487067 Mar 4 1.1162015 9.849261633 -4.96546310 Apr 4 -1.3816511 9.616990375 -0.23533932 May 4 -1.0613234 9.384719118 -2.32339571 Jun 4 0.1505911 9.285099575 -1.43569070 Jul 4 -0.3647653 9.185480033 -0.82071469 Aug 4 0.2281005 9.343415083 -0.57151553 Sep 4 0.5482439 9.501350132 2.95040594 Oct 4 0.1598676 9.922393116 -2.08226077 Nov 4 -1.8648721 10.343436100 2.52143599 Dec 4 -0.5763206 10.802597730 -2.22627717 Jan 5 0.8403693 11.261759359 -2.10212866 Feb 5 2.2055590 11.663812223 1.13062876 Mar 5 1.1162015 12.065865086 -1.18206655 Apr 5 -1.3816511 12.435271255 1.94637980 May 5 -1.0613234 12.804677424 0.25664598 Jun 5 0.1505911 13.164620012 1.68478887 Jul 5 -0.3647653 13.524562600 -0.15979725 Aug 5 0.2281005 13.825297014 -1.05339747 Sep 5 0.5482439 14.126031428 1.32572464 Oct 5 0.1598676 14.284749432 -0.44461708 Nov 5 -1.8648721 14.443467436 -0.57859534 Dec 5 -0.5763206 14.413603690 1.16271687 Jan 6 0.8403693 14.383739944 -1.22410924 Feb 6 2.2055590 14.088917877 2.70552310 Mar 6 1.1162015 13.794095811 1.08970273 Apr 6 -1.3816511 13.326933293 4.05471776 May 6 -1.0613234 12.859770775 -0.79844737 Jun 6 0.1505911 12.513049949 0.33635893 Jul 6 -0.3647653 12.166329123 0.19843622 Aug 6 0.2281005 11.922454539 -1.15055499 Sep 6 0.5482439 11.678579954 -6.22682388 Oct 6 0.1598676 11.548488351 -2.70835600 Nov 6 -1.8648721 11.418396749 -3.55352465 Dec 6 -0.5763206 11.506337688 4.06998287 Jan 7 0.8403693 11.594278628 4.56535207 Feb 7 2.2055590 11.785049619 -0.99060864 Mar 7 1.1162015 11.975820610 -1.09202207 Apr 7 -1.3816511 12.037611855 2.34403920 May 7 -1.0613234 12.099403101 -1.03807970 Jun 7 0.1505911 11.893031546 1.95637733 Jul 7 -0.3647653 11.686659991 1.67810536 Aug 7 0.2281005 11.413577602 -1.64167805 Sep 7 0.5482439 11.140495213 -0.68873914 Oct 7 0.1598676 10.922045234 0.91808712 Nov 7 -1.8648721 10.703595256 -1.83872316 Dec 7 -0.5763206 10.508925771 1.06739479 Jan 8 0.8403693 10.314256287 -2.15462559 Feb 8 2.2055590 10.102002409 0.69243857 Mar 8 1.1162015 9.889748531 0.99405000 Apr 8 -1.3816511 9.534332976 -3.15268192 May 8 -1.0613234 9.178917421 4.88240598 Jun 8 0.1505911 8.537839789 2.31156909 Jul 8 -0.3647653 7.896762156 0.46800319 Aug 8 0.2281005 6.932510318 0.83938923 Sep 8 0.5482439 5.968258480 1.48349759 Oct 8 0.1598676 4.896028931 2.94410342 Nov 8 -1.8648721 3.823799383 -1.95892729 Dec 8 -0.5763206 2.868253927 0.70806663 Jan 9 0.8403693 1.912708471 -2.75307777 Feb 9 2.2055590 1.278078873 -4.48363789 Mar 9 1.1162015 0.643449274 -2.75965074 Apr 9 -1.3816511 0.294655942 -2.91300489 May 9 -1.0613234 -0.054137390 2.11546080 Jun 9 0.1505911 -0.108986226 -1.04160489 Jul 9 -0.3647653 -0.163835062 0.52860041 Aug 9 0.2281005 -0.087541126 -1.14055933 Sep 9 0.5482439 -0.011247189 5.46300326 Oct 9 0.1598676 0.002434146 -0.16230180 Nov 9 -1.8648721 0.016115481 -1.15124339 Dec 9 -0.5763206 0.052286052 -2.47596549 Jan 10 0.8403693 0.088456623 3.07117408 Feb 10 2.2055590 0.321865659 -1.52742468 Mar 10 1.1162015 0.555274695 -1.67147616 Apr 10 -1.3816511 0.970174562 -3.58852351 May 10 -1.0613234 1.385074428 -2.32375102 Jun 10 0.1505911 1.910122497 0.93928638 Jul 10 -0.3647653 2.435170566 -0.07040522 Aug 10 0.2281005 2.916434278 1.85546527 Sep 10 0.5482439 3.397697989 2.05405808 Oct 10 0.1598676 3.775389010 2.06474334 Nov 10 -1.8648721 4.153080031 0.71179206 Dec 10 -0.5763206 4.255502642 0.32081792 Jan 11 0.8403693 4.357925253 1.80170545 Feb 11 2.2055590 4.277685968 -1.48324499 Mar 11 1.1162015 4.197446683 0.68635185 Apr 11 -1.3816511 4.254815080 -1.87316403 May 11 -1.0613234 4.312183476 -0.25086007 Jun 11 0.1505911 4.387563007 1.46184587 Jul 11 -0.3647653 4.462942539 -4.09817719 Aug 11 0.2281005 4.544566937 -1.77266739 Sep 11 0.5482439 4.626191334 -1.17443526 Oct 11 0.1598676 4.734046938 2.10608541 Nov 11 -1.8648721 4.841902541 3.02296955 > m$win s t l 1311 19 13 > m$deg s t l 0 1 1 > m$jump s t l 132 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1jdj71293398601.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/html/rcomp/tmp/2u4is1293398601.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/html/rcomp/tmp/3u4is1293398601.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/html/rcomp/tmp/45dzv1293398601.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/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/51nx41293398601.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/6movs1293398601.tab") > > try(system("convert tmp/1jdj71293398601.ps tmp/1jdj71293398601.png",intern=TRUE)) character(0) > try(system("convert tmp/2u4is1293398601.ps tmp/2u4is1293398601.png",intern=TRUE)) character(0) > try(system("convert tmp/3u4is1293398601.ps tmp/3u4is1293398601.png",intern=TRUE)) character(0) > try(system("convert tmp/45dzv1293398601.ps tmp/45dzv1293398601.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.308 0.658 2.854