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(567,557,547,527,729,719,567,466,476,476,486,507,446,385,335,335,527,547,395,223,314,314,385,426,416,314,365,345,517,476,314,193,304,335,365,405,324,254,284,294,557,557,405,385,446,416,497,598,618,476,436,395,669,689,638,689,679,598,689,790,831,709,628,689,952,1033,1013,1053,1043,942,1114,1155,1215,1033,962,1043,1236,1408,1367,1367,1387,1317,1499,1499,1468,1296,1327,1347,1479,1651,1529,1590,1539,1509,1742,1691,1620,1519,1620,1671,1732,1813,1732,1782,1721,1711,1964,1985,1904,1762,1883,1934,1995,2086,1995,2066,2035,1924,2157,2157) > 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/1b35f1404765614.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/2ycts1404765614.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/3enpb1404765614.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.018824549 -0.301986004 -0.309541444 -0.140978471 [6] 0.190852603 0.300883386 0.175921974 -0.089054299 -0.332194097 [11] -0.286095534 0.065177671 0.798075195 0.003712058 -0.253146964 [16] -0.244844689 -0.117961955 0.127749920 0.273777856 0.152474509 [21] -0.087003376 -0.325826062 -0.188697704 0.079860088 0.605627502 [26] -0.041276289 -0.189777761 -0.144880920 -0.140591100 0.033656248 [31] 0.280753672 0.155529892 -0.050006238 -0.330126900 -0.180607622 [36] 0.077294228 0.424389395 -0.026066830 -0.115765325 -0.068780263 [41] -0.163475163 -0.056741915 0.274997293 0.183463051 -0.016867859 [46] -0.316541882 -0.159935684 0.038171240 0.317651873 > (mypacf <- c(rpacf$acf)) [1] 0.018824549 -0.302447544 -0.326406917 -0.304052574 -0.070767219 [6] 0.095333208 0.211288178 0.185086855 -0.031076584 -0.240320447 [11] -0.235228752 0.676253082 -0.030330976 0.081409580 0.126610917 [16] 0.182792799 -0.102700501 0.015301555 -0.035769911 -0.122721377 [21] -0.096017313 0.175508652 -0.048412824 -0.064577009 -0.054911124 [26] 0.100501038 0.054747124 -0.125445081 -0.166637147 0.074903391 [31] 0.059856766 0.106054768 -0.059086572 -0.134806870 -0.082886455 [36] -0.121528135 0.009806402 -0.133603789 -0.005208128 0.023961038 [41] 0.085699334 0.061353937 0.090621170 -0.034845544 -0.019587857 [46] 0.038986759 -0.023294621 -0.016508772 > 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/47h801404765614.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/5kn2u1404765614.tab") > > try(system("convert tmp/1b35f1404765614.ps tmp/1b35f1404765614.png",intern=TRUE)) character(0) > try(system("convert tmp/2ycts1404765614.ps tmp/2ycts1404765614.png",intern=TRUE)) character(0) > try(system("convert tmp/3enpb1404765614.ps tmp/3enpb1404765614.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.142 0.195 1.342