R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" Copyright (C) 2016 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(58109,57087,56064,54019,74712,73689,58109,47763,48785,48785,49808,51964,45718,39462,34339,34339,54019,56064,40484,22859,32183,32183,39462,43663,42640,32183,37417,35362,52987,48785,32183,19782,31160,34339,37417,41507,33205,26038,29116,30138,57087,57087,41507,39462,45718,42640,50942,61288,63343,48785,44685,40484,68567,70622,65388,70622,69589,61288,70622,80968,85169,72667,64365,70622,97570,105872,103827,107916,106894,96548,114173,118374,124519,105872,98593,106894,126675,144300,140099,140099,142154,134976,153634,153634,150455,132820,135999,138054,151579,169204,156701,162958,157724,154656,178538,173304,166025,155679,166025,171259,177505,185806,177505,182628,176381,175359,201285,203441,195140,180583,192984,198208,204464,213788,204464,211743,208564,197185,221066,221066) > par2 = '12' > par1 = 'additive' > par2 <- '12' > par1 <- 'additive' > #'GNU S' R Code compiled by R2WASP v. 1.2.327 () > #Author: root > #To cite this work: Wessa P., (2013), Classical Decomposition (v1.0.4) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_decompose.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > # > par2 <- as.numeric(par2) > x <- ts(x,freq=par2) > m <- decompose(x,type=par1) > m$figure [1] 4026.793 -9868.277 -10318.939 -9319.360 7544.409 12754.779 [7] 1538.061 -2080.749 -1453.156 -6067.253 5454.168 7789.524 > postscript(file="/var/wessaorg/rcomp/tmp/1dmal1471218457.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/2iajb1471218457.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/3x77a1471218457.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/4xscf1471218457.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/5f6r91471218457.tab") > > try(system("convert tmp/1dmal1471218457.ps tmp/1dmal1471218457.png",intern=TRUE)) character(0) > try(system("convert tmp/2iajb1471218457.ps tmp/2iajb1471218457.png",intern=TRUE)) character(0) > try(system("convert tmp/3x77a1471218457.ps tmp/3x77a1471218457.png",intern=TRUE)) character(0) > try(system("convert tmp/4xscf1471218457.ps tmp/4xscf1471218457.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.119 0.146 2.291