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(785.8,819.3,849.4,880.4,900.1,937.2,948.9,952.6,947.3,974.2,1000.8,1032.8,1050.7,1057.3,1075.4,1118.4,1179.8,1227,1257.8,1251.5,1236.3,1170.6,1213.1,1265.5,1300.8,1348.4,1371.9,1403.3,1451.8,1474.2,1438.2,1513.6,1562.2,1546.2,1527.5,1418.7,1448.5,1492.1,1395.4,1403.7,1316.6,1274.5,1264.4,1323.9,1332.1,1250.2,1096.7,1080.8,1039.2,792,746.6,688.8,715.8,672.9,629.5,681.2,755.4,760.6,765.9,836.8,904.9) > 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 27.333039 821.0480 -62.5810051 Feb 1 -21.749804 839.3243 1.7255142 Mar 1 -34.824670 857.6006 26.6240559 Apr 1 -24.936351 875.9731 29.3632094 May 1 -12.328055 894.3457 18.0823866 Jun 1 -9.719922 913.2288 33.6910895 Jul 1 -20.851794 932.1120 37.6397986 Aug 1 17.667687 951.1999 -16.2676139 Sep 1 41.487150 970.2879 -64.4750089 Oct 1 19.309475 989.3601 -34.4695465 Nov 1 3.871804 1008.4323 -11.5040880 Dec 1 14.741520 1033.0044 -14.9458753 Jan 2 27.333039 1057.5764 -34.2094651 Feb 2 -21.749804 1083.3637 -4.3139411 Mar 2 -34.824670 1109.1511 1.0736053 Apr 2 -24.936351 1131.1614 12.1749856 May 2 -12.328055 1153.1717 38.9563895 Jun 2 -9.719922 1171.9539 64.7659975 Jul 2 -20.851794 1190.7362 87.9156116 Aug 2 17.667687 1210.5606 23.2716904 Sep 2 41.487150 1230.3851 -35.5722133 Oct 2 19.309475 1251.4048 -100.1142663 Nov 2 3.871804 1272.4245 -63.1963231 Dec 2 14.741520 1294.5566 -43.7980775 Jan 3 27.333039 1316.6886 -43.2216342 Feb 3 -21.749804 1342.2293 27.9205373 Mar 3 -34.824670 1367.7699 38.9547311 Apr 3 -24.936351 1394.2909 33.9454602 May 3 -12.328055 1420.8118 43.3162128 Jun 3 -9.719922 1438.9001 45.0198244 Jul 3 -20.851794 1456.9884 2.0634421 Aug 3 17.667687 1464.5421 31.3902561 Sep 3 41.487150 1472.0958 48.6170875 Oct 3 19.309475 1469.2719 57.6185998 Nov 3 3.871804 1466.4481 57.1801081 Dec 3 14.741520 1453.8937 -49.9351785 Jan 4 27.333039 1441.3392 -20.1722677 Feb 4 -21.749804 1422.4033 91.4464696 Mar 4 -34.824670 1403.4674 26.7572292 Apr 4 -24.936351 1378.4811 50.1552059 May 4 -12.328055 1353.4948 -24.5667939 Jun 4 -9.719922 1319.7984 -35.5784327 Jul 4 -20.851794 1286.1019 -0.8500655 Aug 4 17.667687 1239.6490 66.5832955 Sep 4 41.487150 1193.1962 97.4166739 Oct 4 19.309475 1138.6679 92.2226140 Nov 4 3.871804 1084.1396 8.6885502 Dec 4 14.741520 1027.6620 38.3965060 Jan 5 27.333039 971.1843 40.6826594 Feb 5 -21.749804 917.8897 -104.1398766 Mar 5 -34.824670 864.5951 -83.1703902 Apr 5 -24.936351 832.8091 -119.0727695 May 5 -12.328055 801.0232 -72.8951251 Jun 5 -9.719922 788.1298 -105.5099117 Jul 5 -20.851794 775.2365 -124.8846922 Aug 5 17.667687 764.5154 -100.9831353 Sep 5 41.487150 753.7944 -39.8815608 Oct 5 19.309475 746.1843 -4.8937388 Nov 5 3.871804 738.5741 23.4540792 Dec 5 14.741520 734.6918 87.3667092 Jan 6 27.333039 730.8094 146.7575368 > m$win s t l 611 19 13 > m$deg s t l 0 1 1 > m$jump s t l 62 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1p82m1259693314.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/21nll1259693314.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/3mavo1259693314.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/4dmv81259693314.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/5pubj1259693314.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/6087h1259693314.tab") > > system("convert tmp/1p82m1259693314.ps tmp/1p82m1259693314.png") > system("convert tmp/21nll1259693314.ps tmp/21nll1259693314.png") > system("convert tmp/3mavo1259693314.ps tmp/3mavo1259693314.png") > system("convert tmp/4dmv81259693314.ps tmp/4dmv81259693314.png") > > > proc.time() user system elapsed 0.958 0.616 1.115