R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(383,349,317,401,285,377,380,347,414,406,487,475,566,604,764,725,585,797,740,587,719,621,677,636,591,636,748,571,475,758,554,597,521,597,658,482,567,605,653,512,653,498,520,606,601,608,732,585,800,721,689,689,777,681,836,594,662,835,702,630,857,847,820,801,900,763,897,687,682,844,687,671) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/11ncb1420535559.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/2qe8h1420535559.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/3gkv31420535559.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.530378205 -0.058493379 0.234196205 -0.031080461 [6] -0.056269752 0.092295028 -0.205286906 0.108629540 0.186593693 [11] -0.315015056 -0.012233967 0.373011014 -0.425883951 0.221640757 [16] -0.034705509 -0.073940241 0.140763673 -0.110611253 -0.076022889 [21] 0.181851938 -0.069480049 -0.200061968 0.261214285 -0.077979386 [26] -0.143553038 0.213413612 -0.235179720 0.211783213 -0.077439684 [31] -0.150121816 0.191409049 0.021320681 -0.129452858 0.024931866 [36] 0.130804409 -0.137796224 0.133944167 -0.087942608 -0.078444498 [41] 0.276808450 -0.216039440 -0.048303090 0.152169704 -0.028442570 [46] -0.099096446 0.092931211 -0.005496258 -0.042067465 > (mypacf <- c(rpacf$acf)) [1] -0.530378205 -0.472791027 -0.111555349 0.131176988 0.187670899 [6] 0.239277468 -0.196110816 -0.348245183 0.052037560 0.076833362 [11] -0.183503586 0.166900257 -0.182803847 0.017553349 0.008128406 [16] 0.015838375 0.092243323 -0.159425854 -0.128906635 -0.041563467 [21] -0.034512620 -0.123971171 0.008450187 -0.009750886 -0.003293872 [26] 0.003074875 -0.209590107 0.045106028 -0.119073333 -0.162053424 [31] 0.030370700 0.010456598 0.147808847 0.062668047 -0.047819222 [36] -0.096732364 -0.007297873 0.014080788 0.010233385 -0.057147834 [41] 0.035071143 -0.016514272 -0.131666503 0.099454145 -0.045761919 [46] 0.020624218 0.142484928 0.012669872 > 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/4oz7m1420535559.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/5x71w1420535559.tab") > > try(system("convert tmp/11ncb1420535559.ps tmp/11ncb1420535559.png",intern=TRUE)) character(0) > try(system("convert tmp/2qe8h1420535559.ps tmp/2qe8h1420535559.png",intern=TRUE)) character(0) > try(system("convert tmp/3gkv31420535559.ps tmp/3gkv31420535559.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.166 0.259 1.433