R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 The R Foundation for Statistical Computing 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(107.00,116.14,117.18,102.28,109.43,114.28,117.39,116.66,114.29,114.18,114.12,122.62,115.70,127.91,119.55,115.08,116.63,121.38,123.41,120.70,119.40,116.83,116.40,121.67,116.54,129.61,119.93,117.64,121.01,124.20,125.23,123.24,121.58,120.89,117.77,110.91,124.23,127.70,129.45,120.13,122.02,126.59,126.34,125.15,125.02,124.40,127.55,126.63,130.18,136.95,136.81,129.59,133.37,140.02,139.67,139.99,134.57,134.41,134.99,135.70) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '48' > #'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/1ct281394703528.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/2b7tx1394703528.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/32kmp1394703528.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.738292953 0.632000608 0.602369989 0.583252695 [6] 0.543286122 0.466507294 0.403469963 0.330978033 0.271661552 [11] 0.178861994 0.207147017 0.274477711 0.149600780 0.087804848 [16] 0.072212850 0.093831285 0.083979104 0.064985819 0.053917784 [21] 0.014962886 0.001792148 -0.079806176 -0.022625982 -0.003751672 [26] -0.026433670 -0.052163963 -0.046852494 -0.066506547 -0.072078208 [31] -0.060322320 -0.066952406 -0.078195309 -0.141178799 -0.150886527 [36] -0.137945341 -0.139071858 -0.186771673 -0.217928897 -0.177809890 [41] -0.188541484 -0.206139098 -0.213198963 -0.248239739 -0.255593942 [46] -0.281823977 -0.309168690 -0.318317613 -0.300328739 > (mypacf <- c(rpacf$acf)) [1] 0.738292953 0.191074147 0.191312829 0.131973500 0.046403297 [6] -0.066514135 -0.054679119 -0.102106257 -0.066792074 -0.145310768 [11] 0.171587632 0.260860327 -0.206465813 -0.044854121 -0.011419461 [16] 0.026013605 -0.018891236 0.017414782 0.027680563 -0.088520554 [21] 0.001664205 -0.120230202 0.083331779 -0.034731871 0.092197799 [26] 0.031923360 0.036222039 -0.148646038 -0.021929628 -0.017742689 [31] -0.020016910 -0.023208373 -0.124636955 0.119323419 -0.082746366 [36] 0.005965283 -0.124872422 -0.021119836 0.107721874 0.037634324 [41] -0.024430904 -0.095249928 -0.178270350 -0.093051759 0.051124825 [46] -0.146449976 0.018837994 0.037159326 > 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/4eudn1394703528.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/5p0wo1394703528.tab") > > try(system("convert tmp/1ct281394703528.ps tmp/1ct281394703528.png",intern=TRUE)) character(0) > try(system("convert tmp/2b7tx1394703528.ps tmp/2b7tx1394703528.png",intern=TRUE)) character(0) > try(system("convert tmp/32kmp1394703528.ps tmp/32kmp1394703528.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.272 0.452 2.732