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(8.9,8.8,8.3,7.5,7.2,7.4,8.8,9.3,9.3,8.7,8.2,8.3,8.5,8.6,8.5,8.2,8.1,7.9,8.6,8.7,8.7,8.5,8.4,8.5,8.7,8.7,8.6,8.5,8.3,8,8.2,8.1,8.1,8,7.9,7.9,8,8,7.9,8,7.7,7.2,7.5,7.3,7,7,7,7.2,7.3,7.1,6.8,6.4,6.1,6.5,7.7,7.9,7.5,6.9,6.6,6.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 0.27769949 8.230751 0.391549743 Feb 1 0.25415122 8.256131 0.289718213 Mar 1 0.05060302 8.281510 -0.032113381 Apr 1 -0.23058857 8.304857 -0.574268346 May 1 -0.45178037 8.328203 -0.676423102 Jun 1 -0.51507809 8.344808 -0.429729718 Jul 1 0.26162402 8.361412 0.176963836 Aug 1 0.38037554 8.377745 0.541879658 Sep 1 0.25912736 8.394077 0.646795192 Oct 1 -0.02448564 8.431714 0.292771389 Nov 1 -0.20809872 8.469351 -0.061252322 Dec 1 -0.05354931 8.479072 -0.125522942 Jan 2 0.27769949 8.488793 -0.266492960 Feb 2 0.25415122 8.464242 -0.118393634 Mar 2 0.05060302 8.439691 0.009705628 Apr 2 -0.23058857 8.427989 0.002599655 May 2 -0.45178037 8.416286 0.135493891 Jun 2 -0.51507809 8.427352 -0.012273554 Jul 2 0.26162402 8.438417 -0.100040828 Aug 2 0.38037554 8.451259 -0.131634441 Sep 2 0.25912736 8.464101 -0.023228341 Oct 2 -0.02448564 8.478366 0.046119786 Nov 2 -0.20809872 8.492631 0.115468006 Dec 2 -0.05354931 8.494278 0.059271642 Jan 3 0.27769949 8.495925 -0.073624120 Feb 3 0.25415122 8.465238 -0.019389352 Mar 3 0.05060302 8.434552 0.114845351 Apr 3 -0.23058857 8.383642 0.346946412 May 3 -0.45178037 8.332733 0.419047681 Jun 3 -0.51507809 8.274523 0.240555101 Jul 3 0.26162402 8.216313 -0.277937310 Aug 3 0.38037554 8.153036 -0.433411736 Sep 3 0.25912736 8.089759 -0.248886450 Oct 3 -0.02448564 8.036466 -0.011980471 Nov 3 -0.20809872 7.983173 0.124925599 Dec 3 -0.05354931 7.938696 0.014853327 Jan 4 0.27769949 7.894219 -0.171918345 Feb 4 0.25415122 7.832293 -0.086444479 Mar 4 0.05060302 7.770368 0.079029322 Apr 4 -0.23058857 7.688359 0.542229172 May 4 -0.45178037 7.606351 0.545429231 Jun 4 -0.51507809 7.525295 0.189782943 Jul 4 0.26162402 7.444239 -0.205863176 Aug 4 0.38037554 7.354494 -0.434869327 Sep 4 0.25912736 7.264748 -0.523875765 Oct 4 -0.02448564 7.165876 -0.141390374 Nov 4 -0.20809872 7.067004 0.141095109 Dec 4 -0.05354931 7.016889 0.236660620 Jan 5 0.27769949 6.966774 0.055526733 Feb 5 0.25415122 6.975116 -0.129267072 Mar 5 0.05060302 6.983458 -0.234060943 Apr 5 -0.23058857 6.993832 -0.363243782 May 5 -0.45178037 7.004207 -0.452426413 Jun 5 -0.51507809 7.007712 0.007365977 Jul 5 0.26162402 7.011217 0.427158536 Aug 5 0.38037554 7.019345 0.500279652 Sep 5 0.25912736 7.027472 0.213400480 Oct 5 -0.02448564 7.038310 -0.113824128 Nov 5 -0.20809872 7.049147 -0.241048644 Dec 5 -0.05354931 7.059670 -0.106120320 > 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/17s6z1259694131.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/21x041259694131.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/3jwmd1259694131.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/46sd91259694131.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/55eyo1259694132.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/6j2151259694132.tab") > > system("convert tmp/17s6z1259694131.ps tmp/17s6z1259694131.png") > system("convert tmp/21x041259694131.ps tmp/21x041259694131.png") > system("convert tmp/3jwmd1259694131.ps tmp/3jwmd1259694131.png") > system("convert tmp/46sd91259694131.ps tmp/46sd91259694131.png") > > > proc.time() user system elapsed 0.984 0.613 1.172