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(2540.9,2370.3,1807.5,1834.8,786.8,1561.4,1347.2,1549.8,1553.8,1822.5,3078.7,1589.1,1791.5,2558.1,2111.8,2083.1,2052.1,2243.5,2622,1952.6,808.9,1709.8,1582.1,865.6,1116.1,1119.4,2350,1975.6,2536.5,2785,2819.7,1829.5,758.3,2921.6,2482,1892.7,1855.1,2151.3,1642.2,1640.5,1366.1,1532.8,824.4,-518.7,-978.5,1162.5,1243.4,1199.5,883.1,1437.2,534.5,-1901.9,-2521.1,-1721.1,-3094.5,-3694.8,-2492.1,-464.6,-626.1,-1711.4) > par8 = 'FALSE' > par7 = '1' > par6 = '' > par5 = '1' > par4 = '' > par3 = '0' > par2 = 'periodic' > par1 = '4' > 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 1 Q1 -398.6832 2600.4558 339.12732340 1 Q2 421.2672 2264.3413 -315.30850652 1 Q3 306.8765 1931.0704 -430.44696590 1 Q4 -329.4618 1619.1651 545.09671673 2 Q1 -398.6832 1441.8069 -256.32377839 2 Q2 421.2672 1302.5926 -162.45978788 2 Q3 306.8765 1386.7943 -346.47080998 2 Q4 -329.4618 1561.1597 318.10208984 3 Q1 -398.6832 1783.0897 169.39346996 3 Q2 421.2672 1993.5557 -592.32286537 3 Q3 306.8765 2061.4865 710.33693858 3 Q4 -329.4618 2177.0421 -258.48030258 4 Q1 -398.6832 2126.5128 63.67033263 4 Q2 421.2672 2071.1640 65.66883428 4 Q3 306.8765 2148.9778 -344.05438061 4 Q4 -329.4618 2179.9177 232.64409099 5 Q1 -398.6832 2201.6375 249.14565052 5 Q2 421.2672 2214.8271 -392.59427331 5 Q3 306.8765 2083.0366 232.08684143 5 Q4 -329.4618 1869.6423 412.41949764 6 Q1 -398.6832 1621.3990 -413.81579440 6 Q2 421.2672 1354.4208 -65.88796453 6 Q3 306.8765 1275.2849 -0.06144683 6 Q4 -329.4618 1257.2178 -62.15597167 7 Q1 -398.6832 1252.3267 262.45644704 7 Q2 421.2672 1462.8457 -764.71287539 7 Q3 306.8765 1801.8362 241.28727890 7 Q4 -329.4618 2244.5488 60.51295825 8 Q1 -398.6832 2495.6039 439.57926539 8 Q2 421.2672 2522.1104 -158.37759049 8 Q3 306.8765 2290.4754 222.34808434 8 Q4 -329.4618 2047.4375 111.52429185 9 Q1 -398.6832 1995.8170 -838.83383736 9 Q2 421.2672 2010.5501 489.78266487 9 Q3 306.8765 2176.5636 -1.44018175 9 Q4 -329.4618 2196.8019 25.35988551 10 Q1 -398.6832 2011.6275 242.15568413 10 Q2 421.2672 1836.3615 -106.32871631 10 Q3 306.8765 1734.0980 -398.77453626 10 Q4 -329.4618 1644.7502 325.21160247 11 Q1 -398.6832 1482.1410 282.64214230 11 Q2 421.2672 1082.4621 29.07065185 11 Q3 306.8765 503.6153 13.90814422 11 Q4 -329.4618 115.0719 -304.31010552 12 Q1 -398.6832 120.5286 -700.34538900 12 Q2 421.2672 438.3211 302.91165204 12 Q3 306.8765 921.1750 15.34850124 12 Q4 -329.4618 1183.5511 345.41068792 13 Q1 -398.6832 1136.9781 144.80511159 13 Q2 421.2672 674.3340 341.59881504 13 Q3 306.8765 -161.4335 389.05692822 13 Q4 -329.4618 -1049.9805 -522.45766573 14 Q1 -398.6832 -1879.3598 -243.05704080 14 Q2 421.2672 -2525.3854 383.01821926 14 Q3 306.8765 -2810.5137 -590.86280761 14 Q4 -329.4618 -2678.0301 -687.30815697 15 Q1 -398.6832 -2124.6811 31.26426707 15 Q2 421.2672 -1644.3724 758.50524118 15 Q3 306.8765 -1212.4438 279.46728405 15 Q4 -329.4618 -828.3314 -553.60684338 > m$win s t l 601 7 5 > m$deg s t l 0 1 1 > m$jump s t l 61 1 1 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1bi8x1293457672.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/2bi8x1293457672.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/3y70b1293457672.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/4y70b1293457672.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/5npfn1293457672.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/68qdt1293457672.tab") > > try(system("convert tmp/1bi8x1293457672.ps tmp/1bi8x1293457672.png",intern=TRUE)) character(0) > try(system("convert tmp/2bi8x1293457672.ps tmp/2bi8x1293457672.png",intern=TRUE)) character(0) > try(system("convert tmp/3y70b1293457672.ps tmp/3y70b1293457672.png",intern=TRUE)) character(0) > try(system("convert tmp/4y70b1293457672.ps tmp/4y70b1293457672.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.990 0.651 2.609