R version 2.8.0 (2008-10-20) Copyright (C) 2008 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. Natural language support but running in an English locale 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(3106.54,3125.67,3039.71,3051.67,3112.83,3228.01,3223.98,3328.8,3264.26,3394.14,3549.25,3744.63,3839.25,3912.28,3911.06,3675.8,3703.32,3795.91,3906.01,4070.78,4144.38,4140.3,4388.53,4433.57,4305.23,4471.65,4614.76,4697.86,4639.4,4384.47,4350.83,4325.29,4441.82,4162.5,4127.47,3722.23,3757.12,3719.52,3925.43,3751.41,3168.22,2994.38,3136,2672.2,2100.18,1881.46,1908.64,1900.09,1696.58,1748.74,1953.35,2071.37,2030.98,2169.14,2229.85,2480.93,2525.93,2475.14,2529.66,2453.37,2386.53,2517.3,2457.46,2589.73,2679.07,2506.13,2592.31) > 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 -44.876654 2944.314 207.102736 Feb 1 19.373532 3001.769 104.527154 Mar 1 84.073878 3059.225 -103.588587 Apr 1 72.827612 3118.515 -139.673000 May 1 -11.767127 3177.806 -53.208940 Jun 1 -49.411339 3237.826 39.595034 Jul 1 15.731207 3297.847 -89.597749 Aug 1 48.907418 3358.561 -78.668238 Sep 1 -17.858819 3419.275 -137.156277 Oct 1 -91.931576 3483.246 2.825701 Nov 1 8.603735 3547.217 -6.570390 Dec 1 -33.671812 3602.495 175.807073 Jan 2 -44.876654 3657.773 226.353833 Feb 2 19.373532 3714.260 178.646578 Mar 2 84.073878 3770.747 56.239164 Apr 2 72.827612 3828.382 -225.410074 May 2 -11.767127 3886.018 -170.930838 Jun 2 -49.411339 3941.656 -96.334638 Jul 2 15.731207 3997.294 -107.015195 Aug 2 48.907418 4058.771 -36.898614 Sep 2 -17.858819 4120.248 41.990416 Oct 2 -91.931576 4190.708 41.523427 Nov 2 8.603735 4261.168 118.758370 Dec 2 -33.671812 4317.345 149.896818 Jan 3 -44.876654 4373.522 -23.415438 Feb 3 19.373532 4401.211 51.065592 Mar 3 84.073878 4428.900 101.786464 Apr 3 72.827612 4425.218 199.813925 May 3 -11.767127 4421.537 229.629858 Jun 3 -49.411339 4383.483 50.397883 Jul 3 15.731207 4345.430 -10.330849 Aug 3 48.907418 4281.338 -4.955000 Sep 3 -17.858819 4217.246 242.433298 Oct 3 -91.931576 4129.845 124.586518 Nov 3 8.603735 4042.445 76.421669 Dec 3 -33.671812 3931.907 -176.005058 Jan 4 -44.876654 3821.369 -19.372488 Feb 4 19.373532 3677.752 22.394350 Mar 4 84.073878 3534.135 307.221028 Apr 4 72.827612 3360.381 318.201445 May 4 -11.767127 3186.627 -6.639666 Jun 4 -49.411339 3004.905 38.885853 Jul 4 15.731207 2823.184 297.084615 Aug 4 48.907418 2650.167 -26.874063 Sep 4 -17.858819 2477.149 -359.110292 Oct 4 -91.931576 2339.030 -365.638592 Nov 4 8.603735 2200.911 -300.874961 Dec 4 -33.671812 2123.890 -190.128370 Jan 5 -44.876654 2046.869 -305.412482 Feb 5 19.373532 2037.521 -308.154074 Mar 5 84.073878 2028.172 -158.895825 Apr 5 72.827612 2072.402 -73.859445 May 5 -11.767127 2116.632 -73.884593 Jun 5 -49.411339 2177.638 40.913634 Jul 5 15.731207 2238.644 -24.524897 Aug 5 48.907418 2294.787 137.235175 Sep 5 -17.858819 2350.931 192.857695 Oct 5 -91.931576 2388.321 178.750959 Nov 5 8.603735 2425.710 95.346154 Dec 5 -33.671812 2452.167 34.874820 Jan 6 -44.876654 2478.624 -47.217218 Feb 6 19.373532 2502.165 -4.238689 Mar 6 84.073878 2525.706 -152.320319 Apr 6 72.827612 2546.684 -29.781780 May 6 -11.767127 2567.662 123.175231 Jun 6 -49.411339 2587.209 -31.667366 Jul 6 15.731207 2606.756 -30.176721 > m$win s t l 671 19 13 > m$deg s t l 0 1 1 > m$jump s t l 68 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/freestat/rcomp/tmp/12vf71293630006.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/www/html/freestat/rcomp/tmp/2d4fa1293630006.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/www/html/freestat/rcomp/tmp/3d4fa1293630006.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/www/html/freestat/rcomp/tmp/4nvwd1293630006.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/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/5j5um1293630006.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/freestat/rcomp/tmp/6n6as1293630006.tab") > > try(system("convert tmp/12vf71293630006.ps tmp/12vf71293630006.png",intern=TRUE)) character(0) > try(system("convert tmp/2d4fa1293630006.ps tmp/2d4fa1293630006.png",intern=TRUE)) character(0) > try(system("convert tmp/3d4fa1293630006.ps tmp/3d4fa1293630006.png",intern=TRUE)) character(0) > try(system("convert tmp/4nvwd1293630006.ps tmp/4nvwd1293630006.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.445 0.875 1.578