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(15836.8,17570.4,18252.1,16196.7,16643,17729,16446.1,15993.8,16373.5,17842.2,22321.5,22786.7,18274.1,22392.9,23899.3,21343.5,22952.3,21374.4,21164.1,20906.5,17877.4,20664.3,22160,19813.6,17735.4,19640.2,20844.4,19823.1,18594.6,21350.6,18574.1,18924.2,17343.4,19961.2,19932.1,19464.6,16165.4,17574.9,19795.4,19439.5,17170,21072.4,17751.8,17515.5,18040.3,19090.1,17746.5,19202.1,15141.6,16258.1,18586.5,17209.4,17838.7,19123.5,16583.6,15991.2,16704.4,17420.4,17872,17823.2) > 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 -1978.60795 16082.74 1732.663152 Feb 1 15.74496 16376.09 1178.562535 Mar 1 1541.69741 16669.44 40.962378 Apr 1 21.74866 16993.76 -818.811327 May 1 -187.82104 17318.09 -487.264094 Jun 1 1299.11280 17660.19 -1230.301297 Jul 1 -730.25396 18002.29 -825.937908 Aug 1 -944.91479 18351.85 -1413.132925 Sep 1 -1520.31695 18701.40 -807.586617 Oct 1 214.35386 19150.47 -1522.622588 Nov 1 1231.96278 19599.53 1490.003331 Dec 1 1037.29507 20047.84 1701.562846 Jan 2 -1978.60795 20496.15 -243.442328 Feb 2 15.74496 20802.11 1575.044559 Mar 2 1541.69741 21108.07 1249.531906 Apr 2 21.74866 21202.75 118.998074 May 2 -187.82104 21297.44 1842.685181 Jun 2 1299.11280 21186.56 -1111.277467 Jul 2 -730.25396 21075.69 818.660478 Aug 2 -944.91479 20872.74 978.669893 Sep 2 -1520.31695 20669.80 -1272.079365 Oct 2 214.35386 20448.78 1.165305 Nov 2 1231.96278 20227.77 700.271867 Dec 2 1037.29507 20053.02 -1276.711035 Jan 3 -1978.60795 19878.27 -164.258626 Feb 3 15.74496 19758.36 -133.902064 Mar 3 1541.69741 19638.45 -335.745040 Apr 3 21.74866 19557.84 243.514689 May 3 -187.82104 19477.23 -694.804643 Jun 3 1299.11280 19383.76 667.726526 Jul 3 -730.25396 19290.30 14.058288 Aug 3 -944.91479 19178.85 690.267782 Sep 3 -1520.31695 19067.40 -203.681398 Oct 3 214.35386 18960.88 785.963442 Nov 3 1231.96278 18854.37 -154.229826 Dec 3 1037.29507 18771.70 -344.395364 Jan 4 -1978.60795 18689.03 -545.025591 Feb 4 15.74496 18637.85 -1078.691332 Mar 4 1541.69741 18586.66 -332.956614 Apr 4 21.74866 18548.24 869.507722 May 4 -187.82104 18509.83 -1152.007005 Jun 4 1299.11280 18451.29 1321.995153 Jul 4 -730.25396 18392.76 89.297903 Aug 4 -944.91479 18286.47 173.944691 Sep 4 -1520.31695 18180.18 1380.432806 Oct 4 214.35386 18051.54 824.207494 Nov 4 1231.96278 17922.89 -1408.355927 Dec 4 1037.29507 17799.14 365.663027 Jan 5 -1978.60795 17675.39 -555.182708 Feb 5 15.74496 17570.97 -1328.619152 Mar 5 1541.69741 17466.56 -421.755136 Apr 5 21.74866 17420.05 -232.398090 May 5 -187.82104 17373.54 652.979894 Jun 5 1299.11280 17326.90 497.491285 Jul 5 -730.25396 17280.25 33.603268 Aug 5 -944.91479 17241.60 -305.480597 Sep 5 -1520.31695 17202.94 1021.776864 Oct 5 214.35386 17167.32 38.721780 Nov 5 1231.96278 17131.71 -491.671412 Dec 5 1037.29507 17094.32 -308.413137 > 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/12cit1259951107.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/2b43v1259951107.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/3v1at1259951107.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/4u0ts1259951107.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/5mpj01259951107.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/6uv211259951107.tab") > system("convert tmp/12cit1259951107.ps tmp/12cit1259951107.png") > system("convert tmp/2b43v1259951107.ps tmp/2b43v1259951107.png") > system("convert tmp/3v1at1259951107.ps tmp/3v1at1259951107.png") > system("convert tmp/4u0ts1259951107.ps tmp/4u0ts1259951107.png") > > > proc.time() user system elapsed 0.946 0.601 1.127