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(2756.76,2849.27,2921.44,2981.85,3080.58,3106.22,3119.31,3061.26,3097.31,3161.69,3257.16,3277.01,3295.32,3363.99,3494.17,3667.03,3813.06,3917.96,3895.51,3801.06,3570.12,3701.61,3862.27,3970.1,4138.52,4199.75,4290.89,4443.91,4502.64,4356.98,4591.27,4696.96,4621.4,4562.84,4202.52,4296.49,4435.23,4105.18,4116.68,3844.49,3720.98,3674.4,3857.62,3801.06,3504.37,3032.6,3047.03,2962.34,2197.82,2014.45,1862.83,1905.41,1810.99,1670.07,1864.44,2052.02,2029.6,2070.83,2293.41,2443.27) > 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 -58.15008 2877.748 -62.837994 Feb 1 -104.64856 2911.874 42.044329 Mar 1 -62.27098 2946.000 37.710594 Apr 1 -32.20994 2981.806 32.253597 May 1 -16.37289 3017.612 79.340584 Jun 1 -49.45298 3055.829 99.844232 Jul 1 78.49496 3094.045 -53.230150 Aug 1 113.28856 3133.529 -185.557844 Sep 1 13.32810 3173.013 -89.031472 Oct 1 -21.27133 3220.973 -38.011787 Nov 1 29.33917 3268.933 -41.112036 Dec 1 109.92636 3335.547 -168.463180 Jan 2 -58.15008 3402.161 -48.690687 Feb 2 -104.64856 3465.666 2.972438 Mar 2 -62.27098 3529.171 27.269506 Apr 2 -32.20994 3581.730 117.510286 May 2 -16.37289 3634.288 195.145050 Jun 2 -49.45298 3686.190 281.222837 Jul 2 78.49496 3738.092 78.922597 Aug 2 113.28856 3794.925 -107.153115 Sep 2 13.32810 3851.757 -294.964761 Oct 2 -21.27133 3911.119 -188.237907 Nov 2 29.33917 3970.482 -137.550987 Dec 2 109.92636 4035.059 -174.885185 Jan 3 -58.15008 4099.636 97.034254 Feb 3 -104.64856 4174.412 129.986964 Mar 3 -62.27098 4249.187 103.973617 Apr 3 -32.20994 4310.974 165.145644 May 3 -16.37289 4372.761 146.251654 Jun 3 -49.45298 4400.780 5.652513 Jul 3 78.49496 4428.800 83.975345 Aug 3 113.28856 4422.439 161.232375 Sep 3 13.32810 4416.078 191.993471 Oct 3 -21.27133 4377.195 206.916564 Nov 3 29.33917 4338.311 -165.130276 Dec 3 109.92636 4274.456 -87.892387 Jan 4 -58.15008 4210.601 282.779138 Feb 4 -104.64856 4129.071 80.757590 Mar 4 -62.27098 4047.541 131.409984 Apr 4 -32.20994 3945.428 -68.727758 May 4 -16.37289 3843.314 -105.961518 Jun 4 -49.45298 3710.951 12.901623 Jul 4 78.49496 3578.588 200.536736 Aug 4 113.28856 3412.879 274.892057 Sep 4 13.32810 3247.170 243.871444 Oct 4 -21.27133 3069.698 -15.826729 Nov 4 29.33917 2892.226 125.465166 Dec 4 109.92636 2717.868 134.545745 Jan 5 -58.15008 2543.510 -287.540039 Feb 5 -104.64856 2396.138 -277.039718 Mar 5 -62.27098 2248.766 -323.665454 Apr 5 -32.20994 2199.135 -261.515544 May 5 -16.37289 2149.505 -322.141652 Jun 5 -49.45298 2110.955 -391.432475 Jul 5 78.49496 2072.406 -286.461326 Aug 5 113.28856 2041.801 -103.069725 Sep 5 13.32810 2011.196 5.075942 Oct 5 -21.27133 1991.309 100.792154 Nov 5 29.33917 1971.422 292.648434 Dec 5 109.92636 1960.148 373.195982 > 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/1ba031259919058.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/2rbps1259919058.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/3g71v1259919058.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/4ge2r1259919058.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/5b33a1259919058.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/6amvn1259919058.tab") > > system("convert tmp/1ba031259919058.ps tmp/1ba031259919058.png") > system("convert tmp/2rbps1259919058.ps tmp/2rbps1259919058.png") > system("convert tmp/3g71v1259919058.ps tmp/3g71v1259919058.png") > system("convert tmp/4ge2r1259919058.ps tmp/4ge2r1259919058.png") > > > proc.time() user system elapsed 0.950 0.604 1.543