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(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) > 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.067395875 1.307969 0.159427141 Feb 1 -0.079188655 1.407046 -0.127857401 Mar 1 -0.050981762 1.506123 -0.455141617 Apr 1 0.002528346 1.602633 0.094838453 May 1 0.236038037 1.699143 0.464818942 Jun 1 0.284510083 1.793798 -0.078308121 Jul 1 0.272982154 1.888453 -0.061435210 Aug 1 0.103480355 1.981911 -0.085391724 Sep 1 0.013978374 2.075370 -0.289348056 Oct 1 -0.048770854 2.151823 0.596948155 Nov 1 -0.291519272 2.228276 0.363243555 Dec 1 -0.375661509 2.277226 -0.001564817 Jan 2 -0.067395875 2.326177 -0.258781059 Feb 2 -0.079188655 2.370599 0.008589185 Mar 2 -0.050981762 2.415022 0.435959756 Apr 2 0.002528346 2.446252 -0.048780273 May 2 0.236038037 2.477482 -0.413519884 Jun 2 0.284510083 2.513619 -0.098128967 Jul 2 0.272982154 2.549756 -0.122738076 Aug 2 0.103480355 2.582705 0.213814355 Sep 2 0.013978374 2.615655 0.370366968 Oct 2 -0.048770854 2.630727 -0.381955852 Nov 2 -0.291519272 2.645799 -0.054279483 Dec 2 -0.375661509 2.635879 0.539782148 Jan 3 -0.067395875 2.625960 0.241435908 Feb 3 -0.079188655 2.579476 0.299712307 Mar 3 -0.050981762 2.532993 -0.282010968 Apr 3 0.002528346 2.469699 0.127772749 May 3 0.236038037 2.406405 0.157556884 Jun 3 0.284510083 2.340204 -0.124714263 Jul 3 0.272982154 2.274003 -0.146985436 Aug 3 0.103480355 2.209514 -0.012994605 Sep 3 0.013978374 2.145025 -0.259003592 Oct 3 -0.048770854 2.074042 -0.325270861 Nov 3 -0.291519272 2.003058 0.288461060 Dec 3 -0.375661509 1.915594 0.560067485 Jan 4 -0.067395875 1.828130 -0.060733960 Feb 4 -0.079188655 1.751661 0.127527917 Mar 4 -0.050981762 1.675192 0.175790121 Apr 4 0.002528346 1.664189 0.133282492 May 4 0.236038037 1.653187 -0.589224718 Jun 4 0.284510083 1.735752 -0.720262146 Jul 4 0.272982154 1.818317 -0.791299601 Aug 4 0.103480355 1.998844 -0.902324657 Sep 4 0.013978374 2.179371 -0.793349530 Oct 4 -0.048770854 2.451391 -0.202620123 Nov 4 -0.291519272 2.723411 0.468108472 Dec 4 -0.375661509 3.074972 0.400689093 Jan 5 -0.067395875 3.426534 0.140861843 Feb 5 -0.079188655 3.766255 -0.087066429 Mar 5 -0.050981762 4.105976 0.345005625 Apr 5 0.002528346 4.224640 -0.127168511 May 5 0.236038037 4.343304 0.520657771 Jun 5 0.284510083 4.415254 1.100235876 Jul 5 0.272982154 4.487204 1.139813956 Aug 5 0.103480355 4.549496 0.747023624 Sep 5 0.013978374 4.611788 0.874233475 Oct 5 -0.048770854 4.655123 0.193647705 Nov 5 -0.291519272 4.698458 -1.206938875 Dec 5 -0.375661509 4.720348 -1.644686260 > m$win s t l 601 19 13 > m$deg s t l 0 1 1 > m$jump s t l 61 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1m2uc1259949372.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/2t5br1259949372.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/3vaq11259949372.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/42ya61259949372.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/5p46z1259949372.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/6zrlm1259949372.tab") > system("convert tmp/1m2uc1259949372.ps tmp/1m2uc1259949372.png") > system("convert tmp/2t5br1259949372.ps tmp/2t5br1259949372.png") > system("convert tmp/3vaq11259949372.ps tmp/3vaq11259949372.png") > system("convert tmp/42ya61259949372.ps tmp/42ya61259949372.png") > > > proc.time() user system elapsed 0.951 0.591 1.510