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(108.8,128.4,121.1,119.5,128.7,108.7,105.5,119.8,111.3,110.6,120.1,97.5,107.7,127.3,117.2,119.8,116.2,111,112.4,130.6,109.1,118.8,123.9,101.6,112.8,128,129.6,125.8,119.5,115.7,113.6,129.7,112,116.8,127,112.1,114.2,121.1,131.6,125,120.4,117.7,117.5,120.6,127.5,112.3,124.5,115.2,104.7,130.9,129.2,113.5,125.6,107.6,107,121.6,110.7,106.3,118.6,104.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 -8.214329 117.5710 -0.55669980 Feb 1 9.378478 117.1641 1.85737291 Mar 1 8.071292 116.7573 -3.72856174 Apr 1 3.105160 116.3671 0.02773231 May 1 4.519018 115.9769 8.20403764 Jun 1 -5.371615 115.6193 -1.54764165 Jul 1 -6.262256 115.2616 -3.49931363 Aug 1 7.077391 114.9150 -2.19235101 Sep 1 -3.182962 114.5683 -0.08538749 Oct 1 -4.208880 114.2718 0.53705267 Nov 1 5.785199 113.9753 0.33949547 Dec 1 -10.696492 114.0108 -5.81428420 Jan 2 -8.214329 114.0462 1.86808252 Feb 2 9.378478 114.4400 3.48153535 Mar 2 8.071292 114.8337 -5.70501917 Apr 2 3.105160 115.2863 1.40850604 May 2 4.519018 115.7389 -4.05795746 Jun 2 -5.371615 116.1601 0.21148778 Jul 2 -6.262256 116.5813 2.08094033 Aug 2 7.077391 117.0395 6.48315612 Sep 2 -3.182962 117.4976 -5.21462719 Oct 2 -4.208880 117.9429 5.06596959 Nov 2 5.785199 118.3882 -0.27343099 Dec 2 -10.696492 118.6494 -6.35289275 Jan 3 -8.214329 118.9105 2.10379188 Feb 3 9.378478 119.0238 -0.40226846 Mar 3 8.071292 119.1370 2.39166385 Apr 3 3.105160 119.3277 3.36718780 May 3 4.519018 119.5183 -4.53727696 Jun 3 -5.371615 119.7153 1.35629722 Jul 3 -6.262256 119.9124 -0.05012128 Aug 3 7.077391 119.9514 2.67123006 Sep 3 -3.182962 119.9904 -4.80741770 Oct 3 -4.208880 119.9809 1.02799535 Nov 3 5.785199 119.9714 1.24341105 Dec 3 -10.696492 120.0434 2.75307596 Jan 4 -8.214329 120.1154 2.29888727 Feb 4 9.378478 120.2165 -8.49498218 Mar 4 8.071292 120.3176 3.21114102 Apr 4 3.105160 120.3958 1.49900861 May 4 4.519018 120.4741 -4.59311251 Jun 4 -5.371615 120.4636 2.60804111 Jul 4 -6.262256 120.4531 3.30920204 Aug 4 7.077391 120.4022 -6.87954341 Sep 4 -3.182962 120.3513 10.33171204 Oct 4 -4.208880 120.0919 -3.58303106 Nov 4 5.785199 119.8326 -1.11777152 Dec 4 -10.696492 119.3421 6.55437553 Jan 5 -8.214329 118.8517 -5.93733103 Feb 5 9.378478 118.1871 3.33441750 Mar 5 8.071292 117.5225 3.60615867 Apr 5 3.105160 116.8579 -6.46301922 May 5 4.519018 116.1932 4.88781418 Jun 5 -5.371615 115.5902 -2.61857481 Jul 5 -6.262256 114.9872 -1.72495650 Aug 5 7.077391 114.3863 0.13626509 Sep 5 -3.182962 113.7855 0.09748758 Oct 5 -4.208880 113.1919 -2.68298578 Nov 5 5.785199 112.5983 0.21654351 Dec 5 -10.696492 112.0189 3.27758619 > 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/1lahb1260522563.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/2f57c1260522563.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/3on251260522563.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/4nlck1260522563.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/5492o1260522564.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/6xhz51260522564.tab") > system("convert tmp/1lahb1260522563.ps tmp/1lahb1260522563.png") > system("convert tmp/2f57c1260522563.ps tmp/2f57c1260522563.png") > system("convert tmp/3on251260522563.ps tmp/3on251260522563.png") > system("convert tmp/4nlck1260522563.ps tmp/4nlck1260522563.png") > > > proc.time() user system elapsed 0.976 0.628 7.436