R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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(236.422 + ,250.580 + ,279.515 + ,264.417 + ,283.706 + ,281.288 + ,271.146 + ,283.944 + ,269.155 + ,270.899 + ,276.507 + ,319.957 + ,250.746 + ,247.772 + ,280.449 + ,274.925 + ,296.013 + ,287.881 + ,279.098 + ,294.763 + ,261.924 + ,291.596 + ,287.537 + ,326.201 + ,255.598 + ,253.086 + ,285.261 + ,284.747 + ,300.402 + ,288.854 + ,295.433 + ,307.256 + ,273.189 + ,287.540 + ,290.705 + ,337.006 + ,268.335 + ,259.060 + ,293.703 + ,294.262 + ,312.404 + ,301.014 + ,309.942 + ,317.079 + ,293.912 + ,304.060 + ,301.299 + ,357.634 + ,281.493 + ,282.478 + ,319.111 + ,315.223 + ,328.445 + ,321.081 + ,328.040 + ,326.362 + ,313.566 + ,319.768 + ,324.315 + ,387.243 + ,293.308 + ,295.109 + ,339.190 + ,335.678 + ,345.401 + ,351.002 + ,351.889 + ,355.773 + ,333.363 + ,336.214 + ,343.910 + ,405.788 + ,318.682 + ,314.189 + ,362.141 + ,351.811 + ,373.727 + ,366.795 + ,362.393 + ,376.006 + ,346.423 + ,349.007 + ,357.224 + ,418.473 + ,329.169 + ,323.456 + ,374.439 + ,358.806 + ,391.816 + ,376.944 + ,372.665 + ,388.357 + ,354.241 + ,368.982 + ,378.233 + ,426.699 + ,343.241 + ,344.577 + ,373.623 + ,369.688 + ,398.816 + ,379.387 + ,384.666 + ,383.879 + ,351.578 + ,350.920 + ,336.629 + ,385.504 + ,311.330 + ,300.545 + ,329.718 + ,331.023 + ,348.944 + ,345.650 + ,349.260 + ,354.597 + ,325.769 + ,339.734 + ,340.543 + ,401.585 + ,315.998 + ,312.327 + ,362.217 + ,358.067 + ,367.321 + ,360.372 + ,363.830 + ,364.525 + ,347.945 + ,357.404 + ,368.182 + ,429.343) > par2 = '12' > par1 = 'additive' > par2 <- as.numeric(par2) > x <- ts(x,freq=par2) > m <- decompose(x,type=par1) > m$figure [1] -31.660293 -35.912331 2.148923 -3.102006 15.061477 5.792823 [7] 6.060640 13.820194 -13.271277 -4.446077 -3.366481 48.874407 > postscript(file="/var/wessaorg/rcomp/tmp/1yu391352555050.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > plot(m) > dev.off() null device 1 > mylagmax <- length(x)/2 > postscript(file="/var/wessaorg/rcomp/tmp/2vms51352555050.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$trend),na.action=na.pass,lag.max = mylagmax,main='Trend') > acf(as.numeric(m$seasonal),na.action=na.pass,lag.max = mylagmax,main='Seasonal') > acf(as.numeric(m$random),na.action=na.pass,lag.max = mylagmax,main='Random') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/3hfqd1352555050.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$trend[!is.na(m$trend)]),main='Trend') > spectrum(as.numeric(m$seasonal[!is.na(m$seasonal)]),main='Seasonal') > spectrum(as.numeric(m$random[!is.na(m$random)]),main='Random') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/48vac1352555050.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$trend[!is.na(m$trend)]),main='Trend') > cpgram(as.numeric(m$seasonal[!is.na(m$seasonal)]),main='Seasonal') > cpgram(as.numeric(m$random[!is.na(m$random)]),main='Random') > par(op) > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Classical Decomposition by Moving Averages',6,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'t',header=TRUE) > a<-table.element(a,'Observations',header=TRUE) > a<-table.element(a,'Fit',header=TRUE) > a<-table.element(a,'Trend',header=TRUE) > a<-table.element(a,'Seasonal',header=TRUE) > a<-table.element(a,'Random',header=TRUE) > a<-table.row.end(a) > for (i in 1:length(m$trend)) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,x[i]) + a<-table.element(a,m$trend[i]+m$seasonal[i]) + a<-table.element(a,m$trend[i]) + a<-table.element(a,m$seasonal[i]) + a<-table.element(a,m$random[i]) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/5ciip1352555050.tab") > > try(system("convert tmp/1yu391352555050.ps tmp/1yu391352555050.png",intern=TRUE)) character(0) > try(system("convert tmp/2vms51352555050.ps tmp/2vms51352555050.png",intern=TRUE)) character(0) > try(system("convert tmp/3hfqd1352555050.ps tmp/3hfqd1352555050.png",intern=TRUE)) character(0) > try(system("convert tmp/48vac1352555050.ps tmp/48vac1352555050.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.231 0.429 3.688