R version 2.10.1 (2009-12-14) 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(20503,22885,26217,26583,27751,28158,27373,28367,26851,26733,26849,26733,27951,29781,32914,33488,35652,36488,35387,35676,34844,32447,31068,29010,29812,30951,32974,32936,34012,32946,31948,30599,27691,25073,23406,22248,22896,25317,26558,26471,27543,26198,24725,25005,23462,20780,19815,19761,21454,23899,24939,23580,24562,24696,23785,23812,21917,19713,19282,18788,21453,24482,27474,27264,27349,30632,29429,30084,26290,24379,23335,21346,21106,24514,28353,30805,31348,34556,33855,34787,32529,29998,29257,28155,30466,35704,39327,39351,42234,43630,43722,43121,37985,37135,34646,33026,35087,38846,42013,43908,42868,44423,44167,43636,44382,42142,43452,36912,42413,45344,44873,47510,49554,47369,45998,48140,48441,44928,40454,38661,37246,36843,36424,37594,38144,38737,34560,36080,33508,35462,33374,32110,35533,35532,37903,36763,40399,44164,44496,43110,43880,43930,44327) > 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 -3122.8661 23088.23 537.63232 Feb 1 -947.8728 23643.94 188.92845 Mar 1 1034.8694 24199.65 982.47575 Apr 1 1405.4382 24777.79 399.76841 May 1 2515.9227 25355.93 -120.85461 Jun 1 3267.3838 25948.21 -1057.59751 Jul 1 2091.0950 26540.50 -1258.59051 Aug 1 2204.0588 27127.70 -964.76337 Sep 1 349.6048 27714.91 -1213.51842 Oct 1 -1406.3513 28342.38 -203.02746 Nov 1 -2695.2233 28969.84 574.37932 Dec 1 -4696.0588 29649.42 1779.63587 Jan 2 -3122.8661 30329.00 744.86425 Feb 2 -947.8728 30947.06 -218.18364 Mar 2 1034.8694 31565.11 314.01964 Apr 2 1405.4382 32022.03 60.52835 May 2 2515.9227 32478.96 657.12137 Jun 2 3267.3838 32745.93 474.68363 Jul 2 2091.0950 33012.91 282.99579 Aug 2 2204.0588 33110.45 361.49519 Sep 2 349.6048 33207.98 1286.41240 Oct 2 -1406.3513 33134.13 719.22013 Nov 2 -2695.2233 33060.28 702.94368 Dec 2 -4696.0588 32803.86 902.19482 Jan 3 -3122.8661 32547.45 387.41778 Feb 3 -947.8728 32104.60 -205.72291 Mar 3 1034.8694 31661.74 277.38757 Apr 3 1405.4382 31075.72 454.84533 May 3 2515.9227 30489.69 1006.38740 Jun 3 3267.3838 29884.94 -206.32402 Jul 3 2091.0950 29280.19 576.71446 Aug 3 2204.0588 28717.46 -322.51602 Sep 3 349.6048 28154.72 -813.32869 Oct 3 -1406.3513 27622.05 -1142.70223 Nov 3 -2695.2233 27089.38 -988.15996 Dec 3 -4696.0588 26576.39 367.67342 Jan 4 -3122.8661 26063.39 -44.52138 Feb 4 -947.8728 25612.61 652.26230 Mar 4 1034.8694 25161.83 361.29715 Apr 4 1405.4382 24791.24 274.32554 May 4 2515.9227 24420.64 606.43824 Jun 4 3267.3838 24159.21 -1228.59098 Jul 4 2091.0950 23897.78 -1263.87030 Aug 4 2204.0588 23741.10 -940.16290 Sep 4 349.6048 23584.43 -472.03769 Oct 4 -1406.3513 23466.75 -1280.40305 Nov 4 -2695.2233 23349.08 -838.85259 Dec 4 -4696.0588 23240.54 1216.52185 Jan 5 -3122.8661 23132.00 1444.86813 Feb 5 -947.8728 23017.93 1828.93950 Mar 5 1034.8694 22903.87 1000.26204 Apr 5 1405.4382 22760.55 -585.98449 May 5 2515.9227 22617.22 -571.14670 Jun 5 3267.3838 22520.87 -1092.25863 Jul 5 2091.0950 22424.53 -730.62067 Aug 5 2204.0588 22509.22 -901.28275 Sep 5 349.6048 22593.92 -1026.52702 Oct 5 -1406.3513 22891.68 -1772.32678 Nov 5 -2695.2233 23189.43 -1212.21071 Dec 5 -4696.0588 23636.42 -152.35915 Jan 6 -3122.8661 24083.40 492.46423 Feb 6 -947.8728 24565.89 863.98518 Mar 6 1034.8694 25048.37 1390.75730 Apr 6 1405.4382 25427.57 430.99314 May 6 2515.9227 25806.76 -973.68670 Jun 6 3267.3838 25974.55 1390.07008 Jul 6 2091.0950 26142.33 1195.57677 Aug 6 2204.0588 26197.49 1682.45039 Sep 6 349.6048 26252.65 -312.25817 Oct 6 -1406.3513 26391.29 -605.94144 Nov 6 -2695.2233 26529.93 -499.70889 Dec 6 -4696.0588 26833.95 -791.89256 Jan 7 -3122.8661 27137.97 -2909.10440 Feb 7 -947.8728 27595.44 -2133.56510 Mar 7 1034.8694 28052.91 -734.77463 Apr 7 1405.4382 28632.15 767.41278 May 7 2515.9227 29211.39 -379.31550 Jun 7 3267.3838 29872.43 1416.18393 Jul 7 2091.0950 30533.47 1230.43326 Aug 7 2204.0588 31288.66 1294.27702 Sep 7 349.6048 32043.86 135.53859 Oct 7 -1406.3513 32825.46 -1421.10462 Nov 7 -2695.2233 33607.06 -1654.83201 Dec 7 -4696.0588 34413.11 -1562.05373 Jan 8 -3122.8661 35219.17 -1630.30362 Feb 8 -947.8728 35976.54 675.32816 Mar 8 1034.8694 36733.92 1558.21111 Apr 8 1405.4382 37341.12 604.44083 May 8 2515.9227 37948.32 1769.75487 Jun 8 3267.3838 38328.79 2033.82789 Jul 8 2091.0950 38709.25 2921.65080 Aug 8 2204.0588 38922.22 1994.72513 Sep 8 349.6048 39135.18 -1499.78273 Oct 8 -1406.3513 39267.34 -725.99354 Nov 8 -2695.2233 39399.51 -2058.28853 Dec 8 -4696.0588 39524.55 -1802.48677 Jan 9 -3122.8661 39649.58 -1439.71319 Feb 9 -947.8728 39914.24 -120.37041 Mar 9 1034.8694 40178.91 799.22354 Apr 9 1405.4382 40655.50 1847.06619 May 9 2515.9227 41132.08 -780.00685 Jun 9 3267.3838 41643.16 -487.54425 Jul 9 2091.0950 42154.24 -78.33175 Aug 9 2204.0588 42593.18 -1161.24163 Sep 9 349.6048 43032.13 1000.26631 Oct 9 -1406.3513 43423.88 124.47105 Nov 9 -2695.2233 43815.63 2331.59162 Dec 9 -4696.0588 44144.72 -2536.66408 Jan 10 -3122.8661 44473.81 1062.05205 Feb 10 -947.8728 44732.78 1559.08892 Mar 10 1034.8694 44991.75 -1153.62304 Apr 10 1405.4382 45129.44 975.12286 May 10 2515.9227 45267.12 1770.95307 Jun 10 3267.3838 45151.52 -1049.90388 Jul 10 2091.0950 45035.92 -1129.01093 Aug 10 2204.0588 44523.06 1412.88488 Sep 10 349.6048 44010.20 4081.19849 Oct 10 -1406.3513 43205.77 3128.58383 Nov 10 -2695.2233 42401.34 747.88499 Dec 10 -4696.0588 41412.66 1944.40052 Jan 11 -3122.8661 40423.98 -55.11211 Feb 11 -947.8728 39353.48 -1562.60482 Mar 11 1034.8694 38282.98 -2893.84636 Apr 11 1405.4382 37399.72 -1211.15539 May 11 2515.9227 36516.46 -888.38010 Jun 11 3267.3838 36092.55 -622.93118 Jul 11 2091.0950 35668.64 -3199.73235 Aug 11 2204.0588 35610.78 -1734.83780 Sep 11 349.6048 35552.92 -2394.52544 Oct 11 -1406.3513 35720.52 1147.83255 Nov 11 -2695.2233 35888.12 181.10637 Dec 11 -4696.0588 36315.37 490.69266 Jan 12 -3122.8661 36742.62 1913.25077 Feb 12 -947.8728 37446.94 -967.06767 Mar 12 1034.8694 38151.27 -1283.13495 Apr 12 1405.4382 38996.46 -3638.90134 May 12 2515.9227 39841.66 -1958.58342 Jun 12 3267.3838 40696.66 199.95584 Jul 12 2091.0950 41551.66 853.24500 Aug 12 2204.0588 42435.93 -1529.99345 Sep 12 349.6048 43320.21 210.18591 Oct 12 -1406.3513 44243.69 1092.66547 Nov 12 -2695.2233 45167.16 1855.06085 > m$win s t l 1431 19 13 > m$deg s t l 0 1 1 > m$jump s t l 144 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/yougetitorg/rcomp/tmp/1v1k51293659559.ps",horizontal=F,onefile=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/yougetitorg/rcomp/tmp/2v1k51293659559.ps",horizontal=F,onefile=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/yougetitorg/rcomp/tmp/3v1k51293659559.ps",horizontal=F,onefile=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/yougetitorg/rcomp/tmp/46s1q1293659559.ps",horizontal=F,onefile=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/yougetitorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/yougetitorg/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/yougetitorg/rcomp/tmp/5kkzg1293659559.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/yougetitorg/rcomp/tmp/653f41293659559.tab") > > try(system("convert tmp/1v1k51293659559.ps tmp/1v1k51293659559.png",intern=TRUE)) character(0) > try(system("convert tmp/2v1k51293659559.ps tmp/2v1k51293659559.png",intern=TRUE)) character(0) > try(system("convert tmp/3v1k51293659559.ps tmp/3v1k51293659559.png",intern=TRUE)) character(0) > try(system("convert tmp/46s1q1293659559.ps tmp/46s1q1293659559.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.970 0.810 2.291