R version 3.3.0 (2016-05-03) -- "Supposedly Educational" Copyright (C) 2016 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(105.95,108.55,110.81,111.54,110.38,106.67,106.45,105.44,105.37,103.72,106.57,108.54,110.36,106.64,103.45,101.36,101.9,100.86,100.37,100.16,99.5,99.52,99.2,99.35,99.37,99.85,99.76,100.07,99.77,99.93,99.16,99.4,99.81,99.67,99.37,99.49,99.28,99.33,99.19,98.11,99.12,99.06,97.41,98.45,100.33,103.18,103.06,103.48,102.8,103.92,103.9,103.96,103.62,103.83,104.09,104.07,103.22,104.01,104.01,104.24,102.93,104.73,106.48,119.5,122.45,125.29,126.56,126.38,127.95,128.23,128.7,127.86) > 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.327 (Mon, 30 Nov 2015 06:58:35 +0000) > #Author: root > #To cite this work: Wessa P., (2015), (Partial) Autocorrelation Function (v1.0.12) 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) > x <- na.omit(x) > 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/11syp1463863119.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/2s9a61463863119.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/3w8dc1463863119.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.9216262085 0.8191304449 0.7050254640 0.5971676283 [6] 0.4944611574 0.3892694267 0.2885730414 0.2033341559 0.1295824019 [11] 0.1067917205 0.0887167176 0.0804852938 0.0691278662 0.0600885144 [16] 0.0489695302 0.0426065393 0.0313348198 0.0185550785 -0.0004740324 [21] -0.0248395266 -0.0547805561 -0.0839464331 -0.1132804980 -0.1398138917 [26] -0.1679064685 -0.1951112753 -0.2214618552 -0.2324138523 -0.2351166697 [31] -0.2321914325 -0.2338296897 -0.2325768237 -0.2254188379 -0.2241430783 [36] -0.2258786972 -0.2268905017 -0.2270930989 -0.2276606937 -0.2297168420 [41] -0.2320450555 -0.2289141109 -0.2238194977 -0.2231235376 -0.2232660957 [46] -0.2230553096 -0.2200078291 -0.2138841477 -0.2063940380 > (mypacf <- c(rpacf$acf)) [1] 0.9216262085 -0.2009521387 -0.1135392490 -0.0054766734 -0.0417055247 [6] -0.1013242170 -0.0393281874 0.0289014232 -0.0250168014 0.2630143261 [11] -0.0968584068 0.0044756813 -0.0413450211 -0.0026144697 -0.0654463693 [16] 0.0291098685 -0.0300693974 -0.0242394616 0.0413851861 -0.0894797310 [21] -0.0334211670 -0.0346665879 -0.0176095120 -0.0476907236 -0.0144766640 [26] -0.0523608127 -0.0344933691 0.0782301564 -0.0361143524 -0.0201441616 [31] -0.0661668741 0.0082237913 0.0007790877 -0.0852266721 -0.0390889252 [36] -0.0076652424 0.0391963469 -0.0508526260 -0.0098219903 -0.0565581847 [41] 0.0364064377 -0.0146437040 -0.0975701097 -0.0230896064 -0.0118802387 [46] 0.0125952650 -0.0343841693 -0.0041382951 > 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/43bul1463863119.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/5w8v51463863119.tab") > > try(system("convert tmp/11syp1463863119.ps tmp/11syp1463863119.png",intern=TRUE)) character(0) > try(system("convert tmp/2s9a61463863119.ps tmp/2s9a61463863119.png",intern=TRUE)) character(0) > try(system("convert tmp/3w8dc1463863119.ps tmp/3w8dc1463863119.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.122 0.198 1.335