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(1.5469,1.5501,1.5494,1.5475,1.5449,1.5391,1.5578,1.5528,1.5496,1.549,1.5449,1.5479,1.5494,1.558,1.5691,1.5748,1.5564,1.5601,1.5687,1.5775,1.5841,1.5898,1.5922,1.5969,1.6155,1.6212,1.6124,1.6375,1.6506,1.6543,1.6567,1.6383,1.6475,1.6706,1.6485,1.6592,1.6203,1.608,1.572,1.5964,1.6247,1.6139,1.6193,1.6212,1.5942,1.5194,1.5162,1.5393,1.4935,1.4904,1.5083,1.5147,1.5118,1.5148,1.5202,1.5236,1.5148,1.5138,1.5105,1.502,1.4765,1.4671,1.4482,1.4337,1.4181,1.3767,1.346,1.3413,1.3089,1.3452,1.3442,1.2811,1.2779,1.2974,1.2867,1.2977,1.2537,1.2092,1.1766,1.1203,1.2005,1.2295,1.2307,1.2276,1.2108,1.2071,1.2061,1.2023,1.2012,1.2011,1.2011,1.2011,1.2089,1.2098,1.2052,1.2091,1.2288,1.2298,1.2266,1.2199,1.2418,1.2322,1.2366,1.2338,1.2338,1.2316,1.2316,1.2245) > 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] -0.0048603733 -0.0007384983 -0.0036322483 0.0056156684 0.0065630642 [6] -0.0021207899 -0.0029431858 -0.0084056858 -0.0010062066 0.0047062934 [11] 0.0036536892 0.0031682726 > postscript(file="/var/wessaorg/rcomp/tmp/1he5m1432671778.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/2gqw51432671778.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/32t3r1432671778.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/41va31432671778.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/5bvdx1432671778.tab") > > try(system("convert tmp/1he5m1432671778.ps tmp/1he5m1432671778.png",intern=TRUE)) character(0) > try(system("convert tmp/2gqw51432671778.ps tmp/2gqw51432671778.png",intern=TRUE)) character(0) > try(system("convert tmp/32t3r1432671778.ps tmp/32t3r1432671778.png",intern=TRUE)) character(0) > try(system("convert tmp/41va31432671778.ps tmp/41va31432671778.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.752 0.239 2.003