R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(50,45,43,40,43,47,44,41,31,41,40,31,43,22,17,21,29,23,15,24,24,27,17,22,26,12,13,20,15,23,27,17,22,16,20,8,24,18,28,25,11,33,34,23,13,23,26,15,29,23,26,17,32,25,26,32,24,24,28,26,27,45,47,29,40,25,35,26,32,21,32,16,35,19,28,29,29,26,35,38,27,28,29,26,40,20,28,34,38,32,51,27,23,44,37,26) > par2 = '12' > par1 = 'multiplicative' > par2 <- as.numeric(par2) > x <- ts(x,freq=par2) > m <- decompose(x,type=par1) > m$figure [1] 1.2150145 0.8472478 1.0065384 0.9570743 1.0256151 1.0476896 1.1507464 [8] 1.0597906 0.9362211 0.9650921 1.0226717 0.7662984 > postscript(file="/var/wessaorg/rcomp/tmp/19e6l1431940871.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/2w65i1431940871.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/3zcgw1431940871.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/42wy81431940871.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]) + if (par1 == 'additive') a<-table.element(a,signif(m$trend[i]+m$seasonal[i],6)) else a<-table.element(a,signif(m$trend[i]*m$seasonal[i],6)) + a<-table.element(a,signif(m$trend[i],6)) + a<-table.element(a,signif(m$seasonal[i],6)) + a<-table.element(a,signif(m$random[i],6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/5gmny1431940871.tab") > > try(system("convert tmp/19e6l1431940871.ps tmp/19e6l1431940871.png",intern=TRUE)) character(0) > try(system("convert tmp/2w65i1431940871.ps tmp/2w65i1431940871.png",intern=TRUE)) character(0) > try(system("convert tmp/3zcgw1431940871.ps tmp/3zcgw1431940871.png",intern=TRUE)) character(0) > try(system("convert tmp/42wy81431940871.ps tmp/42wy81431940871.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.859 0.285 2.155