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(9487,8700,9627,8947,9283,8829,9947,9628,9318,9605,8640,9214,9567,8547,9185,9470,9123,9278,10170,9434,9655,9429,8739,9552,9687,9019,9672,9206,9069,9788,10312,10105,9863,9656,9295,9946,9701,9049,10190,9706,9765,9893,9994,10433,10073,10112,9266,9820,10097,9115,10411,9678,10408,10153,10368,10581,10597,10680,9738,9556) > 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 135.83348 9312.934 38.2320773 Feb 1 -701.24055 9304.491 96.7498277 Mar 1 214.48518 9296.047 116.4678252 Apr 1 -212.61429 9289.417 -129.8024729 May 1 -95.91433 9282.787 96.1278028 Jun 1 -45.25317 9276.889 -402.6361180 Jul 1 516.80749 9270.992 159.2004531 Aug 1 384.28978 9264.990 -21.2802753 Sep 1 238.77213 9258.989 -179.7610643 Oct 1 218.26287 9261.680 125.0572007 Nov 1 -558.24602 9264.371 -66.1249129 Dec 1 -95.18258 9278.152 31.0302550 Jan 2 135.83348 9291.934 139.2328000 Feb 2 -701.24055 9301.756 -53.5153899 Mar 2 214.48518 9311.578 -341.0633327 Apr 2 -212.61429 9317.665 364.9490855 May 2 -95.91433 9323.752 -104.8379227 Jun 2 -45.25317 9337.672 -14.4188282 Jul 2 516.80749 9351.592 301.6007582 Aug 2 384.28978 9373.013 -323.3024412 Sep 2 238.77213 9394.434 21.7942987 Oct 2 218.26287 9409.371 -198.6337566 Nov 2 -558.24602 9424.308 -127.0621906 Dec 2 -95.18258 9444.054 203.1284021 Jan 3 135.83348 9463.800 87.3663720 Feb 3 -701.24055 9493.070 227.1700528 Mar 3 214.48518 9522.341 -64.8260193 Apr 3 -212.61429 9550.766 -132.1515595 May 3 -95.91433 9579.191 -414.2765262 Jun 3 -45.25317 9601.541 231.7122601 Jul 3 516.80749 9623.891 171.3015383 Aug 3 384.28978 9650.182 70.5282404 Sep 3 238.77213 9676.473 -52.2451181 Oct 3 218.26287 9708.588 -270.8504685 Nov 3 -558.24602 9740.702 112.5438024 Dec 3 -95.18258 9761.601 279.5813397 Jan 4 135.83348 9782.500 -217.3337458 Feb 4 -701.24055 9795.992 -45.7519497 Mar 4 214.48518 9809.485 166.0300935 Apr 4 -212.61429 9822.987 95.6268857 May 4 -95.91433 9836.490 24.4242516 Jun 4 -45.25317 9845.009 93.2444323 Jul 4 516.80749 9853.527 -376.3348951 Aug 4 384.28978 9864.008 184.7023012 Sep 4 238.77213 9874.488 -40.2605631 Oct 4 218.26287 9894.532 -0.7945857 Nov 4 -558.24602 9914.575 -90.3289870 Dec 4 -95.18258 9943.371 -28.1885040 Jan 5 135.83348 9972.167 -11.0006440 Feb 5 -701.24055 10005.179 -188.9383040 Mar 5 214.48518 10038.191 158.3242832 Apr 5 -212.61429 10064.781 -174.1667117 May 5 -95.91433 10091.371 412.5428672 Jun 5 -45.25317 10108.183 90.0699805 Jul 5 516.80749 10124.995 -273.8024142 Aug 5 384.28978 10140.093 56.6167347 Sep 5 238.77213 10155.192 203.0358229 Oct 5 218.26287 10169.286 292.4514059 Nov 5 -558.24602 10183.379 112.8666102 Dec 5 -95.18258 10195.735 -544.5523440 > 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/1be071259938428.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/2s82u1259938428.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/3g40g1259938428.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/4ssei1259938428.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/572cc1259938429.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/62zvl1259938429.tab") > system("convert tmp/1be071259938428.ps tmp/1be071259938428.png") > system("convert tmp/2s82u1259938428.ps tmp/2s82u1259938428.png") > system("convert tmp/3g40g1259938428.ps tmp/3g40g1259938428.png") > system("convert tmp/4ssei1259938428.ps tmp/4ssei1259938428.png") > > > proc.time() user system elapsed 0.984 0.622 2.310