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(17409,11514,31514,27071,29462,26105,22397,23843,21705,18089,20764,25316,17704,15548,28029,29383,36438,32034,22679,24319,18004,17537,20366,22782,19169,13807,29743,25591,29096,26482,22405,27044,17970,18730,19684,19785,18479,10698,31956,29506,34506,27165,26736,23691,18157,17328,18205,20995,17382,9367) > 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 -4707.4348 21761.02 355.417366 Feb 1 -10537.7498 21937.44 114.309357 Mar 1 7201.9229 22113.86 2198.213688 Apr 1 4773.5034 22301.81 -4.313719 May 1 9255.5837 22489.76 -2283.340928 Jun 1 4866.2653 22672.16 -1433.426642 Jul 1 513.6941 22854.57 -971.259587 Aug 1 1708.8009 23019.35 -885.148009 Sep 1 -4031.3457 23184.13 2552.216898 Oct 1 -5065.0697 23413.09 -259.016043 Nov 1 -3227.0448 23642.04 349.001979 Dec 1 -751.1268 23897.21 2169.917332 Jan 2 -4707.4348 24152.38 -1740.941387 Feb 2 -10537.7498 24192.66 1893.092535 Mar 2 7201.9229 24232.94 -3405.861202 Apr 2 4773.5034 24121.62 487.881027 May 2 9255.5837 24010.29 3172.123454 Jun 2 4866.2653 23925.26 3242.471003 Jul 2 513.6941 23840.23 -1674.928678 Aug 2 1708.8009 23749.12 -1138.925397 Sep 2 -4031.3457 23658.01 -1622.668788 Oct 2 -5065.0697 23422.41 -820.340243 Nov 2 -3227.0448 23186.81 406.239265 Dec 2 -751.1268 22940.00 593.128202 Jan 3 -4707.4348 22693.19 1183.243069 Feb 3 -10537.7498 22644.96 1699.789827 Mar 3 7201.9229 22596.73 -55.651074 Apr 3 4773.5034 22579.96 -1762.462667 May 3 9255.5837 22563.19 -2722.774062 Jun 3 4866.2653 22482.68 -866.945890 Jul 3 513.6941 22402.17 -510.864949 Aug 3 1708.8009 22413.65 2921.544346 Sep 3 -4031.3457 22425.14 -423.793031 Oct 3 -5065.0697 22616.03 1179.041724 Nov 3 -3227.0448 22806.92 104.127440 Dec 3 -751.1268 22999.39 -2463.266611 Jan 4 -4707.4348 23191.87 -5.434733 Feb 4 -10537.7498 23242.87 -2007.115442 Mar 4 7201.9229 23293.86 1460.216190 Apr 4 4773.5034 23276.10 1456.398239 May 4 9255.5837 23258.34 1992.080486 Jun 4 4866.2653 23081.44 -782.702238 Jul 4 513.6941 22904.54 3317.767807 Aug 4 1708.8009 22700.31 -718.108922 Sep 4 -4031.3457 22496.08 -307.732322 Oct 4 -5065.0697 22261.96 131.109462 Nov 4 -3227.0448 22027.84 -595.797791 Dec 4 -751.1268 21765.67 -19.544858 Jan 5 -4707.4348 21503.50 585.934004 Feb 5 -10537.7498 21223.51 -1318.763133 > m$win s t l 501 19 13 > m$deg s t l 0 1 1 > m$jump s t l 51 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1nidb1259784338.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/24u0l1259784338.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/3c2hu1259784338.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/4jlj31259784338.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/5ia341259784338.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/6xdsy1259784338.tab") > system("convert tmp/1nidb1259784338.ps tmp/1nidb1259784338.png") > system("convert tmp/24u0l1259784338.ps tmp/24u0l1259784338.png") > system("convert tmp/3c2hu1259784338.ps tmp/3c2hu1259784338.png") > system("convert tmp/4jlj31259784338.ps tmp/4jlj31259784338.png") > > > proc.time() user system elapsed 0.926 0.624 2.150