R version 2.12.0 (2010-10-15) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(18992,0,21552,1868501,7185612,10348382,6942386,4306121,2833176,1515513,1242981,699343,89497,128,10585,1070323,7167741,13193530,7885720,6785683,3106846,1706331,1286534,499079,24637,16,27309,873433,8435418,11290088,6840395,3803252,4388988,2680940,1174135,328388,22943,5657,28156,770831,8378147,13274946,7297840,2848227,2892179,1762224,1009375,188388,3393,0,13807,2619905,13297704,6240087,5108460,4553381,3148546,2433387,1748108,723454,58525,792,42585,1634386,10360570,6798599,4847748,4971202,343863,2200366,1549422,90144,63288,338,44863,1678135,9293357,9361258,6766402,4331272,3518962,2425786,1701795,552452,16104,0,90198,1731332,7954135,11561342,6834733,4255652,4243070,3415216,1841237,655456) > par2 = '12' > par1 = 'additive' > par2 <- as.numeric(par2) > x <- ts(x,freq=par2) > m <- decompose(x,type=par1) > m$figure [1] -3204512.4 -3242350.7 -3214646.5 -1788511.9 5983580.3 6956391.6 [7] 3304826.4 1292013.1 -332192.3 -1118643.5 -1838429.7 -2797524.5 > postscript(file="/var/www/rcomp/tmp/10f6m1324222070.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/www/rcomp/tmp/266au1324222070.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/www/rcomp/tmp/3vstx1324222070.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/www/rcomp/tmp/4h93s1324222070.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/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/www/rcomp/tmp/5t9kx1324222070.tab") > > try(system("convert tmp/10f6m1324222070.ps tmp/10f6m1324222070.png",intern=TRUE)) character(0) > try(system("convert tmp/266au1324222070.ps tmp/266au1324222070.png",intern=TRUE)) character(0) > try(system("convert tmp/3vstx1324222070.ps tmp/3vstx1324222070.png",intern=TRUE)) character(0) > try(system("convert tmp/4h93s1324222070.ps tmp/4h93s1324222070.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.380 0.130 1.498