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(103.51,104.35,104.51,105.25,105.2,105.87,107.63,107.77,106.58,106.32,106.3,106.38,106.42,107.35,107.58,108.2,108.29,108.76,110.69,110.56,108.81,108.81,108.81,109.74,109.57,110.44,111.2,111.44,111.83,112.87,115.07,115.35,113.81,114.66,114.51,115.11,114.54,115.39,115.65,116.46,116.18,116.63,118.84,118.77,117.83,117.66,117.36,118,117.34,118.04,118.17,118.82,119,118.89,121.4,121.01,120.21,120.39,120.09,120.76,120.33,120.84,121.49,122.29,121.91,122.46,124.94,124.6,123.09,123.25,123.01,123.82) > 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/16l9u1358029809.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/24xfu1358029809.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/3lph71358029809.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.950581286 0.906072429 0.864438387 0.825662124 [6] 0.778024834 0.729023976 0.699830741 0.671771707 0.634158373 [11] 0.597605547 0.565417966 0.533961030 0.485357844 0.441768276 [16] 0.400584309 0.362027017 0.318352558 0.272601684 0.246560490 [21] 0.219124679 0.182223077 0.146808780 0.114399538 0.086743902 [26] 0.043706883 0.005029101 -0.030312988 -0.065534788 -0.105391487 [31] -0.143635912 -0.163122324 -0.179582094 -0.205868512 -0.226967910 [36] -0.245404770 -0.258816634 -0.285871296 -0.308751428 -0.330443453 [41] -0.345399108 -0.368275503 -0.390528411 -0.394446040 -0.394602340 [46] -0.398533100 -0.402155988 -0.402760406 -0.398247560 > (mypacf <- c(rpacf$acf)) [1] 0.9505812862 0.0255992668 0.0088988155 0.0102773732 -0.1094094232 [6] -0.0479507519 0.1739608538 0.0074800407 -0.1045974700 -0.0048263567 [11] -0.0090311508 -0.0261036865 -0.1521697739 0.0198000455 -0.0387710912 [16] -0.0096162897 -0.0372617722 -0.0601891356 0.1198647750 -0.0173334951 [21] -0.1017425619 -0.0079628084 -0.0350138387 0.0016751036 -0.0995941530 [26] 0.0002103935 -0.0498596963 -0.0505577612 -0.0397542506 -0.0155386980 [31] 0.0866475536 0.0349842255 -0.0987634792 0.0160001189 -0.0333497344 [36] -0.0030764872 -0.0540716994 0.0017416356 -0.0859216482 0.0367930824 [41] -0.0702025300 -0.0324131024 0.0899317420 0.0299657058 -0.0258501189 [46] -0.0222259987 -0.0250676181 -0.0074452144 > 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/4j7q01358029809.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/5c4nw1358029809.tab") > > try(system("convert tmp/16l9u1358029809.ps tmp/16l9u1358029809.png",intern=TRUE)) character(0) > try(system("convert tmp/24xfu1358029809.ps tmp/24xfu1358029809.png",intern=TRUE)) character(0) > try(system("convert tmp/3lph71358029809.ps tmp/3lph71358029809.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.234 0.313 2.527