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(106370,109375,116476,123297,114813,117925,126466,131235,120546,123791,129813,133463,122987,125418,130199,133016,121454,122044,128313,131556,120027,123001,130111,132524,123742,124931,133646,136557,127509,128945,137191,139716,129083,131604,139413,143125,133948,137116,144864,149277,138796,143258,150034,154708,144888,148762,156500,161088,152772,158011,163318,169969,162269,165765,170600,174681,166364,170240,176150,182056,172218,177856,182253,188090,176863,183273,187969,194650,183036,189516,193805,200499,188142,193732,197126,205140,191751,196700,199784,207360,196101,200824,205743,212489,200810,203683,207286,210910,194915,217920) > 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 -5726.950 110945.6 1151.349194 1 Q2 -2377.862 112957.6 -1204.782744 1 Q3 2198.458 114995.4 -717.832116 1 Q4 5906.357 117127.2 263.425110 2 Q1 -5726.950 119418.1 1121.841930 2 Q2 -2377.862 121591.6 -1288.746049 2 Q3 2198.458 123350.8 916.742379 2 Q4 5906.357 124879.9 448.730330 3 Q1 -5726.950 125937.7 335.211421 3 Q2 -2377.862 126621.0 -452.126778 3 Q3 2198.458 127204.8 409.723051 3 Q4 5906.357 127753.3 -196.639693 4 Q1 -5726.950 128000.5 713.481370 4 Q2 -2377.862 127991.1 -195.270414 4 Q3 2198.458 127709.0 291.510748 4 Q4 5906.357 127156.1 -46.428633 5 Q1 -5726.950 126430.6 750.367909 5 Q2 -2377.862 125955.0 -1533.139037 5 Q3 2198.458 125632.0 482.548749 5 Q4 5906.357 125645.6 4.003220 6 Q1 -5726.950 125883.1 -129.143902 6 Q2 -2377.862 126275.7 -896.806020 6 Q3 2198.458 126870.7 1041.839984 6 Q4 5906.357 127625.9 -1008.239821 7 Q1 -5726.950 128226.3 1242.608638 7 Q2 -2377.862 129189.0 -1880.114464 7 Q3 2198.458 130163.1 1284.436924 7 Q4 5906.357 131250.7 -600.047243 8 Q1 -5726.950 132079.4 1156.507299 8 Q2 -2377.862 132935.8 -1612.897051 8 Q3 2198.458 133554.4 1438.151670 8 Q4 5906.357 134137.8 -328.160632 9 Q1 -5726.950 134600.0 209.916425 9 Q2 -2377.862 135329.6 -1347.745456 9 Q3 2198.458 136392.4 822.174179 9 Q4 5906.357 137751.1 -532.501904 10 Q1 -5726.950 139051.8 623.143328 10 Q2 -2377.862 140513.7 -1019.845287 10 Q3 2198.458 141919.8 745.772899 10 Q4 5906.357 143324.1 46.585719 11 Q1 -5726.950 144658.4 -135.496354 11 Q2 -2377.862 146004.6 -368.737527 11 Q3 2198.458 147465.9 369.617458 11 Q4 5906.357 148936.1 -134.411352 12 Q1 -5726.950 150375.4 239.558755 12 Q2 -2377.862 151986.3 -846.478278 12 Q3 2198.458 153767.7 533.853538 12 Q4 5906.357 155923.1 -741.472504 13 Q1 -5726.950 157975.2 523.730372 13 Q2 -2377.862 159938.2 450.636280 13 Q3 2198.458 162112.6 -993.044992 13 Q4 5906.357 164357.2 -294.542146 14 Q1 -5726.950 166377.7 1618.208029 14 Q2 -2377.862 167826.5 316.373801 14 Q3 2198.458 168759.4 -357.895254 14 Q4 5906.357 169850.6 -1075.915087 15 Q1 -5726.950 171192.8 898.141028 15 Q2 -2377.862 172793.5 -175.683260 15 Q3 2198.458 174386.6 -435.021958 15 Q4 5906.357 176101.6 47.994017 16 Q1 -5726.950 177883.0 61.930124 16 Q2 -2377.862 179387.5 846.378098 16 Q3 2198.458 180689.0 -634.450239 16 Q4 5906.357 181893.8 289.870358 17 Q1 -5726.950 183335.1 -745.155637 17 Q2 -2377.862 184859.3 791.553704 17 Q3 2198.458 186483.3 -712.746885 17 Q4 5906.357 187992.1 751.559268 18 Q1 -5726.950 189545.8 -782.881034 18 Q2 -2377.862 190972.3 921.554000 18 Q3 2198.458 192387.6 -781.107263 18 Q4 5906.357 193523.3 1069.353103 19 Q1 -5726.950 194508.6 -639.635459 19 Q2 -2377.862 195392.9 716.925075 19 Q3 2198.458 196484.0 -1556.412836 19 Q4 5906.357 197351.4 1882.284672 20 Q1 -5726.950 198093.9 -615.915390 20 Q2 -2377.862 198538.3 539.511749 20 Q3 2198.458 199373.6 -1788.037783 20 Q4 5906.357 200495.1 958.542863 21 Q1 -5726.950 201831.5 -3.566553 21 Q2 -2377.862 203100.8 101.049833 21 Q3 2198.458 204363.3 -818.715579 21 Q4 5906.357 205401.5 1181.101014 22 Q1 -5726.950 205982.2 554.768188 22 Q2 -2377.862 205879.8 181.057208 22 Q3 2198.458 205015.8 71.747769 22 Q4 5906.357 206835.8 -1832.121710 23 Q1 -5726.950 209662.9 -9020.974819 23 Q2 -2377.862 212716.7 7581.204047 > m$win s t l 901 7 5 > m$deg s t l 0 1 1 > m$jump s t l 91 1 1 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/html/rcomp/tmp/1yq6c1259938384.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/206q01259938384.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/3712o1259938384.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/44x821259938384.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/5kktq1259938384.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/63c7g1259938384.tab") > > system("convert tmp/1yq6c1259938384.ps tmp/1yq6c1259938384.png") > system("convert tmp/206q01259938384.ps tmp/206q01259938384.png") > system("convert tmp/3712o1259938384.ps tmp/3712o1259938384.png") > system("convert tmp/44x821259938384.ps tmp/44x821259938384.png") > > > proc.time() user system elapsed 1.081 0.636 1.263