R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-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(46,62,66,59,58,61,41,27,58,70,49,59,44,36,72,45,56,54,53,35,61,52,47,51,52,63,74,45,51,64,36,30,55,64,39,40,63,45,59,55,40,64,27,28,45,57,45,69,60,56,58,50,51,53,37,22,55,70,62,58,39,49,58,47,42,62,39,40,72,70,54,65) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '1' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '1' > par3 <- '1' > par2 <- '1' > par1 <- '60' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., (2012), (Partial) Autocorrelation Function (v1.0.11) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_autocorrelation.wasp/ > #Source of accompanying publication: > # > if (par1 == 'Default') { + par1 = 10*log10(length(x)) + } else { + par1 <- as.numeric(par1) + } > par2 <- as.numeric(par2) > par3 <- as.numeric(par3) > par4 <- as.numeric(par4) > par5 <- as.numeric(par5) > if (par6 == 'White Noise') par6 <- 'white' else par6 <- 'ma' > par7 <- as.numeric(par7) > if (par8 != '') par8 <- as.numeric(par8) > ox <- x > if (par8 == '') { + if (par2 == 0) { + x <- log(x) + } else { + x <- (x ^ par2 - 1) / par2 + } + } else { + x <- log(x,base=par8) + } > if (par3 > 0) x <- diff(x,lag=1,difference=par3) > if (par4 > 0) x <- diff(x,lag=par5,difference=par4) > postscript(file="/var/wessaorg/rcomp/tmp/1suzf1354640649.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow=c(2,1)) > plot(ox,type='l',main='Original Time Series',xlab='time',ylab='value') > if (par8=='') { + mytitle <- paste('Working Time Series (lambda=',par2,', d=',par3,', D=',par4,')',sep='') + mysub <- paste('(lambda=',par2,', d=',par3,', D=',par4,', CI=', par7, ', CI type=',par6,')',sep='') + } else { + mytitle <- paste('Working Time Series (base=',par8,', d=',par3,', D=',par4,')',sep='') + mysub <- paste('(base=',par8,', d=',par3,', D=',par4,', CI=', par7, ', CI type=',par6,')',sep='') + } > plot(x,type='l', main=mytitle,xlab='time',ylab='value') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/2msrl1354640649.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > racf <- acf(x, par1, main='Autocorrelation', xlab='time lag', ylab='ACF', ci.type=par6, ci=par7, sub=mysub) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/3im691354640649.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > rpacf <- pacf(x,par1,main='Partial Autocorrelation',xlab='lags',ylab='PACF',sub=mysub) > dev.off() null device 1 > (myacf <- c(racf$acf)) [1] 1.000000000 -0.511233320 0.088770696 -0.115484824 0.055387819 [6] -0.042298471 -0.018662722 0.047063489 0.019515049 -0.060163158 [11] -0.005452836 0.324264960 -0.417071887 0.090884297 0.022929502 [16] 0.043842559 -0.015104873 -0.054573813 0.068767412 -0.002082804 [21] -0.096201581 0.039032464 0.133370754 -0.086999475 -0.079588052 [26] 0.207527740 -0.239411720 0.144988022 -0.144962011 0.209091719 [31] -0.108512635 -0.064239118 0.102968574 0.052225760 -0.085521428 [36] -0.025547308 0.041964874 -0.130912691 0.165808371 -0.101436685 [41] 0.150742495 -0.177953040 0.072971643 0.042909778 -0.010027578 [46] -0.076521928 -0.004938441 0.056508304 -0.017644797 0.059192525 [51] -0.056731046 0.045003580 -0.073087959 0.053522933 -0.016128147 [56] -0.011643147 -0.009444590 0.043753248 -0.023426482 > (mypacf <- c(rpacf$acf)) [1] -0.511233320 -0.233657392 -0.256262664 -0.184354003 -0.183561426 [6] -0.231754213 -0.172938637 -0.107065622 -0.182652013 -0.245783429 [11] 0.338064649 -0.021801493 -0.192831697 -0.023784373 -0.020807261 [16] -0.018186042 -0.107145032 -0.133437401 -0.068287568 -0.160527195 [21] -0.341173326 -0.228631619 0.182312188 -0.153807367 0.066194330 [26] -0.102879231 0.001170136 -0.032503938 0.029384010 0.024050460 [31] -0.049990691 -0.043589400 -0.123505914 0.045325844 0.196044573 [36] -0.036124667 -0.054986588 0.001272020 0.026653073 0.009551869 [41] -0.055057604 0.083656945 0.102688817 -0.000784591 -0.118125687 [46] -0.006589065 0.116080743 -0.028806091 0.018879197 -0.004550609 [51] 0.101628915 -0.028971623 0.035909027 -0.002828259 0.009716690 [56] -0.041200145 -0.111946748 -0.083790136 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #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,'Autocorrelation Function',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Time lag k',header=TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/basics.htm','ACF(k)','click here for more information about the Autocorrelation Function'),header=TRUE) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,'P-value',header=TRUE) > a<-table.row.end(a) > for (i in 2:(par1+1)) { + a<-table.row.start(a) + a<-table.element(a,i-1,header=TRUE) + a<-table.element(a,round(myacf[i],6)) + mytstat <- myacf[i]*sqrtn + a<-table.element(a,round(mytstat,4)) + a<-table.element(a,round(1-pt(abs(mytstat),lengthx),6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/4c7ew1354640649.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Partial Autocorrelation Function',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Time lag k',header=TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/basics.htm','PACF(k)','click here for more information about the Partial Autocorrelation Function'),header=TRUE) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,'P-value',header=TRUE) > a<-table.row.end(a) > for (i in 1:par1) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,round(mypacf[i],6)) + mytstat <- mypacf[i]*sqrtn + a<-table.element(a,round(mytstat,4)) + a<-table.element(a,round(1-pt(abs(mytstat),lengthx),6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/5dxf11354640649.tab") > > try(system("convert tmp/1suzf1354640649.ps tmp/1suzf1354640649.png",intern=TRUE)) character(0) > try(system("convert tmp/2msrl1354640649.ps tmp/2msrl1354640649.png",intern=TRUE)) character(0) > try(system("convert tmp/3im691354640649.ps tmp/3im691354640649.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.141 0.464 2.582