R version 2.12.0 (2010-10-15) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-pc-linux-gnu (32-bit) 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(377,370,358,357,349,348,369,381,368,361,351,351,358,354,347,345,343,340,362,370,373,371,354,357,363,364,363,358,357,357,380,378,376,380,379,384,392,394,392,396,392,396,419,421,420,418,410,418,426,428,430,424,423,427,441,449,452,462,455,461,461,463,462,456,455,456,472,472,471,465,459,465,468,467,463,460,462,461,476,476,471,453,443,442,444,438,427,424,416,406,431,434,418,412,404,409,412,406,398,397,385,390,413,413,401,397,397,409,419,424,428,430,424,433,456,459,446,441,439,454,460,457,451,444,437,443,471,469,454,444,436) > 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 3.8352779 367.7366 5.428098e+00 Feb 1 1.8809226 366.6213 1.497785e+00 Mar 1 -2.8916142 365.5060 -4.614347e+00 Apr 1 -5.8957527 364.3786 -1.482892e+00 May 1 -10.7180701 363.2513 -3.533258e+00 Jun 1 -9.9223293 362.0804 -4.158040e+00 Jul 1 10.7825002 360.9094 -2.691911e+00 Aug 1 13.1397900 359.7531 8.107135e+00 Sep 1 6.0425408 358.5967 3.360721e+00 Oct 1 1.1922684 357.6934 2.114308e+00 Nov 1 -6.4761864 356.7901 6.860778e-01 Dec 1 -0.9693496 355.9453 -3.975948e+00 Jan 2 3.8352779 355.1005 -9.357640e-01 Feb 2 1.8809226 354.6842 -2.565117e+00 Mar 2 -2.8916142 354.2679 -4.376288e+00 Apr 2 -5.8957527 354.6062 -3.710399e+00 May 2 -10.7180701 354.9444 -1.226331e+00 Jun 2 -9.9223293 355.7090 -5.786710e+00 Jul 2 10.7825002 356.4737 -5.256179e+00 Aug 2 13.1397900 357.4381 -5.779246e-01 Sep 2 6.0425408 358.4026 8.554868e+00 Oct 2 1.1922684 359.5698 1.023796e+01 Nov 2 -6.4761864 360.7370 -2.607759e-01 Dec 2 -0.9693496 361.8287 -3.859307e+00 Jan 3 3.8352779 362.9204 -3.755628e+00 Feb 3 1.8809226 363.7295 -1.610449e+00 Mar 3 -2.8916142 364.5387 1.352913e+00 Apr 3 -5.8957527 365.6751 -1.779332e+00 May 3 -10.7180701 366.8115 9.066016e-01 Jun 3 -9.9223293 368.8050 -1.882680e+00 Jul 3 10.7825002 370.7986 -1.581050e+00 Aug 3 13.1397900 373.3275 -8.467276e+00 Sep 3 6.0425408 375.8564 -5.898962e+00 Oct 3 1.1922684 378.8079 -2.120353e-04 Nov 3 -6.4761864 381.7595 3.716720e+00 Dec 3 -0.9693496 385.1031 -1.337322e-01 Jan 4 3.8352779 388.4467 -2.819755e-01 Feb 4 1.8809226 391.8663 2.527646e-01 Mar 4 -2.8916142 395.2859 -3.943139e-01 Apr 4 -5.8957527 398.4235 3.472285e+00 May 4 -10.7180701 401.5610 1.157064e+00 Jun 4 -9.9223293 404.4024 1.519922e+00 Jul 4 10.7825002 407.2438 9.736920e-01 Aug 4 13.1397900 410.0065 -2.146308e+00 Sep 4 6.0425408 412.7692 1.188232e+00 Oct 4 1.1922684 415.4147 1.393076e+00 Nov 4 -6.4761864 418.0601 -1.583898e+00 Dec 4 -0.9693496 420.5075 -1.538172e+00 Jan 5 3.8352779 422.9550 -7.902362e-01 Feb 5 1.8809226 425.4459 6.731425e-01 Mar 5 -2.8916142 427.9369 4.954703e+00 Apr 5 -5.8957527 430.9864 -1.090686e+00 May 5 -10.7180701 434.0360 -3.178948e-01 Jun 5 -9.9223293 437.3826 -4.603057e-01 Jul 5 10.7825002 440.7293 -1.051181e+01 Aug 5 13.1397900 443.8625 -8.002318e+00 Sep 5 6.0425408 446.9958 -1.038292e+00 Oct 5 1.1922684 449.8961 1.091159e+01 Nov 5 -6.4761864 452.7965 8.679652e+00 Dec 5 -0.9693496 455.3432 6.626159e+00 Jan 6 3.8352779 457.8898 -7.251244e-01 Feb 6 1.8809226 459.5575 1.561545e+00 Mar 6 -2.8916142 461.2252 3.666396e+00 Apr 6 -5.8957527 461.9310 -3.519968e-02 May 6 -10.7180701 462.6367 3.081384e+00 Jun 6 -9.9223293 462.9992 2.923082e+00 Jul 6 10.7825002 463.3618 -2.144308e+00 Aug 6 13.1397900 463.6617 -4.801527e+00 Sep 6 6.0425408 463.9617 9.957928e-01 Oct 6 1.1922684 464.2998 -4.920800e-01 Nov 6 -6.4761864 464.6380 8.382296e-01 Dec 6 -0.9693496 465.0880 8.813063e-01 Jan 7 3.8352779 465.5381 -1.373408e+00 Feb 7 1.8809226 465.7462 -6.270777e-01 Mar 7 -2.8916142 465.9542 -6.256615e-02 Apr 7 -5.8957527 465.3240 5.717513e-01 May 7 -10.7180701 464.6938 8.024248e+00 Jun 7 -9.9223293 463.0638 7.858541e+00 Jul 7 10.7825002 461.4338 3.783745e+00 Aug 7 13.1397900 458.8211 4.039106e+00 Sep 7 6.0425408 456.2085 8.749005e+00 Oct 7 1.1922684 452.7110 -9.032804e-01 Nov 7 -6.4761864 449.2136 2.626165e-01 Dec 7 -0.9693496 445.1878 -2.218478e+00 Jan 8 3.8352779 441.1621 -9.973631e-01 Feb 8 1.8809226 437.2350 -1.115918e+00 Mar 8 -2.8916142 433.3079 -3.416292e+00 Apr 8 -5.8957527 429.8009 9.481307e-02 May 8 -10.7180701 426.2940 4.240965e-01 Jun 8 -9.9223293 423.3549 -7.432556e+00 Jul 8 10.7825002 420.4158 -1.982969e-01 Aug 8 13.1397900 417.8700 2.990172e+00 Sep 8 6.0425408 415.3243 -3.366820e+00 Oct 8 1.1922684 413.0755 -2.267762e+00 Nov 8 -6.4761864 410.8267 -3.505221e-01 Dec 8 -0.9693496 408.9568 1.012554e+00 Jan 9 3.8352779 407.0869 1.077840e+00 Feb 9 1.8809226 405.5444 -1.425292e+00 Mar 9 -2.8916142 404.0019 -3.110242e+00 Apr 9 -5.8957527 402.9324 -3.669526e-02 May 9 -10.7180701 401.8630 -6.144969e+00 Jun 9 -9.9223293 401.7541 -1.831818e+00 Jul 9 10.7825002 401.6453 5.722446e-01 Aug 9 13.1397900 403.0127 -3.152535e+00 Sep 9 6.0425408 404.3802 -9.422776e+00 Oct 9 1.1922684 407.1243 -1.131654e+01 Nov 9 -6.4761864 409.8683 -6.392118e+00 Dec 9 -0.9693496 413.5664 -3.597006e+00 Jan 10 3.8352779 417.2644 -2.099686e+00 Feb 10 1.8809226 421.3127 8.063444e-01 Mar 10 -2.8916142 425.3611 5.530556e+00 Apr 10 -5.8957527 429.1783 6.717433e+00 May 10 -10.7180701 432.9956 1.722490e+00 Jun 10 -9.9223293 436.2448 6.677488e+00 Jul 10 10.7825002 439.4941 5.723397e+00 Aug 10 13.1397900 441.9785 3.881743e+00 Sep 10 6.0425408 444.4628 -4.505371e+00 Oct 10 1.1922684 446.0130 -6.205306e+00 Nov 10 -6.4761864 447.5632 -2.087058e+00 Dec 10 -0.9693496 448.6671 6.302254e+00 Jan 11 3.8352779 449.7709 6.393774e+00 Feb 11 1.8809226 450.3706 4.748482e+00 Mar 11 -2.8916142 450.9702 2.921371e+00 Apr 11 -5.8957527 450.8464 -9.506690e-01 May 11 -10.7180701 450.7226 -3.004530e+00 Jun 11 -9.9223293 450.4908 2.431552e+00 Jul 11 10.7825002 450.2590 9.958545e+00 Aug 11 13.1397900 449.9514 5.908805e+00 Sep 11 6.0425408 449.6439 -1.686395e+00 Oct 11 1.1922684 449.2185 -6.410766e+00 Nov 11 -6.4761864 448.7931 -6.316954e+00 > m$win s t l 1311 19 13 > m$deg s t l 0 1 1 > m$jump s t l 132 2 2 > m$inner [1] 2 > m$outer [1] 0 > postscript(file="/var/www/rcomp/tmp/13fdh1292840111.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/rcomp/tmp/2w6ck1292840111.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/rcomp/tmp/3w6ck1292840111.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/rcomp/tmp/47fb51292840111.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/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/rcomp/tmp/5lp9w1292840111.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/rcomp/tmp/66qqj1292840111.tab") > > try(system("convert tmp/13fdh1292840111.ps tmp/13fdh1292840111.png",intern=TRUE)) character(0) > try(system("convert tmp/2w6ck1292840111.ps tmp/2w6ck1292840111.png",intern=TRUE)) character(0) > try(system("convert tmp/3w6ck1292840111.ps tmp/3w6ck1292840111.png",intern=TRUE)) character(0) > try(system("convert tmp/47fb51292840111.ps tmp/47fb51292840111.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.570 0.710 2.268