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(95.1,97.0,112.7,102.9,97.4,111.4,87.4,96.8,114.1,110.3,103.9,101.6,94.6,95.9,104.7,102.8,98.1,113.9,80.9,95.7,113.2,105.9,108.8,102.3,99.0,100.7,115.5,100.7,109.9,114.6,85.4,100.5,114.8,116.5,112.9,102.0,106.0,105.3,118.8,106.1,109.3,117.2,92.5,104.2,112.5,122.4,113.3,100.0,110.7,112.8,109.8,117.3,109.1,115.9,96.0,99.8,116.8,115.7,99.4,94.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 -4.2436734 101.5558 -2.2121469 Feb 1 -3.0761986 101.6798 -1.6036337 Mar 1 6.7912801 101.8038 4.1048757 Apr 1 0.4970323 101.8979 0.5051168 May 1 -0.6572046 101.9919 -3.9346531 Jun 1 9.1994119 102.0483 0.1522916 Jul 1 -16.9439742 102.1047 2.2392388 Aug 1 -6.0159324 102.1227 0.6932760 Sep 1 8.8321036 102.1406 3.1273191 Oct 1 8.7189298 102.0324 -0.4513404 Nov 1 2.2257581 101.9242 -0.2500020 Dec 1 -5.3275376 101.7555 5.1720182 Jan 2 -4.2436734 101.5868 -2.7431215 Feb 2 -3.0761986 101.3887 -2.4124962 Mar 2 6.7912801 101.1906 -3.2818748 Apr 2 0.4970323 101.1465 1.1564600 May 2 -0.6572046 101.1024 -2.3452162 Jun 2 9.1994119 101.3455 3.3550404 Jul 2 -16.9439742 101.5887 -3.7447003 Aug 2 -6.0159324 102.0407 -0.3247398 Sep 2 8.8321036 102.4927 1.8752266 Oct 2 8.7189298 102.9646 -5.7834893 Nov 2 2.2257581 103.4364 3.1377926 Dec 2 -5.3275376 103.8441 3.7834033 Jan 3 -4.2436734 104.2518 -1.0081458 Feb 3 -3.0761986 104.6111 -0.8348734 Mar 3 6.7912801 104.9703 3.7383950 Apr 3 0.4970323 105.3101 -5.1071239 May 3 -0.6572046 105.6499 4.9073462 Jun 3 9.1994119 105.9898 -0.5891658 Jul 3 -16.9439742 106.3296 -3.9856752 Aug 3 -6.0159324 106.7076 -0.1916749 Sep 3 8.8321036 107.0856 -1.1176689 Oct 3 8.7189298 107.4171 0.3639610 Nov 3 2.2257581 107.7487 2.9255887 Dec 3 -5.3275376 108.0474 -0.7199037 Jan 4 -4.2436734 108.3462 1.8974439 Feb 4 -3.0761986 108.5600 -0.1838333 Mar 4 6.7912801 108.7738 3.2348855 Apr 4 0.4970323 108.8731 -3.2701478 May 4 -0.6572046 108.9724 0.9848080 Jun 4 9.1994119 109.0895 -1.0889131 Jul 4 -16.9439742 109.2066 0.2373684 Aug 4 -6.0159324 109.3962 0.8197126 Sep 4 8.8321036 109.5858 -5.9179374 Oct 4 8.7189298 109.7965 3.8845341 Nov 4 2.2257581 110.0072 1.0670036 Dec 4 -5.3275376 110.1426 -4.8150542 Jan 5 -4.2436734 110.2779 4.6657282 Feb 5 -3.0761986 110.2420 5.6342313 Mar 5 6.7912801 110.2060 -7.1972696 Apr 5 0.4970323 109.4916 7.3113693 May 5 -0.6572046 108.7772 0.9799973 Jun 5 9.1994119 107.9376 -1.2369779 Jul 5 -16.9439742 107.0979 5.8460495 Aug 5 -6.0159324 106.2163 -0.4003798 Sep 5 8.8321036 105.3347 2.6331968 Oct 5 8.7189298 104.3921 2.5889620 Nov 5 2.2257581 103.4495 -6.2752749 Dec 5 -5.3275376 102.4452 -2.8176629 > 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/1p0361259938186.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/21nyf1259938186.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/36ois1259938186.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/4zmif1259938186.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/5hdnz1259938186.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/67wcj1259938186.tab") > system("convert tmp/1p0361259938186.ps tmp/1p0361259938186.png") > system("convert tmp/21nyf1259938186.ps tmp/21nyf1259938186.png") > system("convert tmp/36ois1259938186.ps tmp/36ois1259938186.png") > system("convert tmp/4zmif1259938186.ps tmp/4zmif1259938186.png") > > > proc.time() user system elapsed 0.975 0.623 2.788