R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 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(145756,145472,145160,144588,150460,150172,145756,142820,143108,143108,143392,143992,143992,141340,140172,141340,145472,144872,139288,134560,133676,131908,133104,134560,133988,132792,130456,132792,134872,134272,127492,124556,121620,119256,118972,120736,118372,117488,116604,121620,122192,119256,111304,107772,102188,99820,100988,102756,102756,101304,100988,105720,109540,107772,101872,98940,92756,88936,91872,94808,94808,90988,90704,95688,98940,97768,91872,88052,79788,76568,77736,82752,83036,75684,78336,84804,87740,85972,78024,72436,65968,60952,63004,67420,66252,59784,61836,68304,71840,69788,61836,58304,53004,47416,48300,52716,53288,47988,48872,56252,58016,55056,44168,38584,31204,23852,26216,29436,28868,23252,26500,34452,37984,36220,29152,23568,17668,10884,12084,14136) > 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/1188a1376734114.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/2tr3e1376734114.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/3w2ye1376734114.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.0000000000 0.9709045438 0.9360793061 0.9019584898 0.8732689108 [6] 0.8459973707 0.8213666564 0.8018726427 0.7839957863 0.7650761868 [11] 0.7455143074 0.7257918087 0.7036067784 0.6726683341 0.6367769843 [16] 0.6011319847 0.5700297254 0.5413583774 0.5153569311 0.4962826414 [21] 0.4797168396 0.4632088058 0.4465535951 0.4302342194 0.4114922836 [26] 0.3852183933 0.3537041420 0.3232973617 0.2961371800 0.2712678642 [31] 0.2482868529 0.2310612319 0.2153684973 0.1996887041 0.1843413192 [36] 0.1690780731 0.1522965782 0.1304682396 0.1037621962 0.0768882837 [41] 0.0518558824 0.0300648262 0.0118451488 -0.0005044854 -0.0115055706 [46] -0.0215304303 -0.0314455563 -0.0420883368 -0.0532590383 > (mypacf <- c(rpacf$acf)) [1] 0.9709045438 -0.1146813118 0.0041007584 0.0746545778 -0.0085045185 [6] 0.0310567354 0.0773768189 0.0034040886 -0.0233268336 -0.0010939569 [11] -0.0063647944 -0.0512961979 -0.1528973447 -0.0788231376 -0.0172622193 [16] 0.0282242405 -0.0069321690 0.0090183563 0.0860706807 0.0055785393 [21] 0.0006466806 0.0227970862 0.0100192528 -0.0378288370 -0.1028815521 [26] -0.0696989227 -0.0004158595 -0.0079650772 -0.0177543942 -0.0134524886 [31] 0.0433670834 -0.0235650167 -0.0040029430 0.0292659102 -0.0015337959 [36] -0.0186854405 -0.0441015713 -0.0580064143 -0.0197131618 -0.0245499606 [41] 0.0001967775 0.0127682122 0.0348804403 -0.0282571388 0.0173799309 [46] 0.0185932252 -0.0166000835 0.0065618072 > 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/4pqtr1376734114.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/5p6rd1376734114.tab") > > try(system("convert tmp/1188a1376734114.ps tmp/1188a1376734114.png",intern=TRUE)) character(0) > try(system("convert tmp/2tr3e1376734114.ps tmp/2tr3e1376734114.png",intern=TRUE)) character(0) > try(system("convert tmp/3w2ye1376734114.ps tmp/3w2ye1376734114.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.782 0.680 3.428