R version 2.9.0 (2009-04-17) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(4716.99,4926.65,4920.10,5170.09,5246.24,5283.61,4979.05,4825.20,4695.12,4711.54,4727.22,4384.96,4378.75,4472.93,4564.07,4310.54,4171.38,4049.38,3591.37,3720.46,4107.23,4101.71,4162.34,4136.22,4125.88,4031.48,3761.36,3408.56,3228.47,3090.45,2741.14,2980.44,3104.33,3181.57,2863.86,2898.01,3112.33,3254.33,3513.47,3587.61,3727.45,3793.34,3817.58,3845.13,3931.86,4197.52,4307.13,4229.43,4362.28,4217.34,4361.28,4327.74,4417.65,4557.68,4650.35,4967.18,5123.42,5290.85,5535.66,5514.06,5493.88,5694.83,5850.41,6116.64,6175.00,6513.58,6383.78,6673.66,6936.61,7300.68,7392.93,7497.31,7584.71,7160.79,7196.19,7245.63,7347.51,7425.75,7778.51,7822.33,8181.22,8371.47,8347.71,8672.11,8802.79,9138.46,9123.29,9023.21,8850.41,8864.58,9163.74,8516.66,8553.44,7555.20,7851.22,7442.00,7992.53,8264.04,7517.39,7200.40,7193.69,6193.58,5104.21,4800.46,4461.61,4398.59,4243.63,4293.82) > par2 = '12' > par1 = 'multiplicative' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: AUTHOR(S), (YEAR), YOUR SOFTWARE TITLE (vNUMBER) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_YOURPAGE.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: Write here your technical program description (don't use hard returns!) > par2 <- as.numeric(par2) > x <- ts(x,freq=par2) > m <- decompose(x,type=par1) > m$figure [1] 1.0162142 1.0231610 1.0212461 1.0026852 1.0002927 0.9861433 0.9649729 [8] 0.9746728 1.0010690 1.0071864 1.0082068 0.9941497 > postscript(file="/var/www/html/rcomp/tmp/12x341259862574.ps",horizontal=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/html/rcomp/tmp/2gemz1259862574.ps",horizontal=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/html/rcomp/tmp/3jneh1259862574.ps",horizontal=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/html/rcomp/tmp/4xdiu1259862574.ps",horizontal=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/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/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,m$trend[i]+m$seasonal[i]) else 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/html/rcomp/tmp/5m1ue1259862574.tab") > system("convert tmp/12x341259862574.ps tmp/12x341259862574.png") > system("convert tmp/2gemz1259862574.ps tmp/2gemz1259862574.png") > system("convert tmp/3jneh1259862574.ps tmp/3jneh1259862574.png") > system("convert tmp/4xdiu1259862574.ps tmp/4xdiu1259862574.png") > > > proc.time() user system elapsed 1.141 0.654 1.381