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(3010,2910,3840,3580,3140,3550,3250,2820,2260,2060,2120,2210,2190,2180,2350,2440,2370,2440,2610,3040,3190,3120,3170,3600,3420,3650,4180,2960,2710,2950,3030,3770,4740,4450,5550,5580,5890,7480,10450,6360,6710,6200,4490,3480,2520,1920,2010,1950,2240,2370,2840,2700,2980,3290,3300,3000,2330,2190,1970,2170,2830,3190,3550,3240,3450,3570,3230,3260,2700) > 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 -112.42986 3173.002 -50.572572 Feb 1 257.21978 3122.158 -469.377391 Mar 1 1165.20288 3071.313 -396.515669 Apr 1 181.67988 3012.307 386.013198 May 1 199.82477 2953.301 -13.125810 Jun 1 307.80795 2889.235 352.957183 Jul 1 -39.20886 2825.169 464.040164 Aug 1 -138.54966 2760.554 197.995161 Sep 1 -419.55688 2695.940 -16.383418 Oct 1 -653.16205 2606.554 106.607818 Nov 1 -440.55844 2517.168 43.390273 Dec 1 -308.26966 2437.669 80.600713 Jan 2 -112.42986 2358.170 -55.739876 Feb 2 257.21978 2355.618 -432.838054 Mar 2 1165.20288 2353.067 -1168.269691 Apr 2 181.67988 2432.928 -174.607762 May 2 199.82477 2512.789 -342.613708 Jun 2 307.80795 2645.271 -513.079312 Jul 2 -39.20886 2777.754 -128.544928 Aug 2 -138.54966 2916.198 262.352057 Sep 2 -419.55688 3054.641 554.915464 Oct 2 -653.16205 3140.439 632.722692 Nov 2 -440.55844 3226.237 384.321140 Dec 2 -308.26966 3250.303 657.966703 Jan 3 -112.42986 3274.369 258.061236 Feb 3 257.21978 3308.274 84.506307 Mar 3 1165.20288 3342.179 -327.382080 Apr 3 181.67988 3450.799 -672.479190 May 3 199.82477 3559.419 -1049.244175 Jun 3 307.80795 3771.120 -1128.928157 Jul 3 -39.20886 3982.821 -913.612152 Aug 3 -138.54966 4326.447 -417.897483 Sep 3 -419.55688 4670.073 489.483608 Oct 3 -653.16205 5057.066 46.096484 Nov 3 -440.55844 5444.058 546.500580 Dec 3 -308.26966 5701.668 186.602111 Jan 4 -112.42986 5959.277 43.152613 Feb 4 257.21978 5962.471 1260.309566 Mar 4 1165.20288 5965.664 3319.133061 Apr 4 181.67988 5738.935 439.385043 May 4 199.82477 5512.206 997.969149 Jun 4 307.80795 5135.373 756.819105 Jul 4 -39.20886 4758.540 -229.330951 Aug 4 -138.54966 4303.264 -684.714828 Sep 4 -419.55688 3847.989 -908.432281 Oct 4 -653.16205 3456.557 -883.395028 Nov 4 -440.55844 3065.125 -614.566555 Dec 4 -308.26966 2860.751 -602.481118 Jan 5 -112.42986 2656.377 -303.946709 Feb 5 257.21978 2610.018 -497.237388 Mar 5 1165.20288 2563.659 -888.861525 Apr 5 181.67988 2586.281 -67.961032 May 5 199.82477 2608.904 171.271585 Jun 5 307.80795 2650.013 332.178804 Jul 5 -39.20886 2691.123 648.086011 Aug 5 -138.54966 2733.942 404.607447 Sep 5 -419.55688 2776.762 -27.204692 Oct 5 -653.16205 2805.046 38.115719 Nov 5 -440.55844 2833.331 -422.772651 Dec 5 -308.26966 2862.177 -383.907419 Jan 6 -112.42986 2891.023 51.406784 Feb 6 257.21978 2931.716 1.064595 Mar 6 1165.20288 2972.408 -587.611053 Apr 6 181.67988 3015.219 43.101449 May 6 199.82477 3058.029 192.146076 Jun 6 307.80795 3106.944 155.247834 Jul 6 -39.20886 3155.859 113.349580 Aug 6 -138.54966 3210.151 188.399121 Sep 6 -419.55688 3264.442 -144.884915 > m$win s t l 691 19 13 > m$deg s t l 0 1 1 > m$jump s t l 70 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1usrf1292944480.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/rcomp/tmp/2n1801292944480.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/rcomp/tmp/3n1801292944480.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/rcomp/tmp/4xt831292944480.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/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/5b2nc1292944480.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/6x34i1292944480.tab") > > try(system("convert tmp/1usrf1292944480.ps tmp/1usrf1292944480.png",intern=TRUE)) character(0) > try(system("convert tmp/2n1801292944480.ps tmp/2n1801292944480.png",intern=TRUE)) character(0) > try(system("convert tmp/3n1801292944480.ps tmp/3n1801292944480.png",intern=TRUE)) character(0) > try(system("convert tmp/4xt831292944480.ps tmp/4xt831292944480.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.996 0.618 2.226