R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C) 2015 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(1.1216,1.0569,1.0486,1.038,0.9865,0.9332,0.9052,0.8683,0.9232,0.8725,0.8903,0.8959,0.8766,0.9188,0.9838,0.9994,1.0731,1.1372,1.1248,1.189,1.2497,1.2046,1.222,1.2977,1.3113,1.2594,1.2199,1.1884,1.2023,1.2582,1.2743,1.2887,1.3106,1.3481,1.3738,1.4486,1.4976,1.5622,1.505,1.318,1.3029,1.3632,1.4303,1.4779,1.3829,1.2708,1.291,1.3583,1.368,1.4391,1.4127,1.3482,1.3108,1.2814,1.2502,1.2967,1.3206,1.3062,1.3242,1.361,1.3696,1.3711,1.3256,1.2498,1.1261,1.1053,1.1117,1.0953) > 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/1nu2x1457705109.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/2qz4x1457705109.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/3gj0c1457705109.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.00000000 0.94946163 0.86521358 0.79051919 0.72829949 0.68700203 [7] 0.64226791 0.56960046 0.49312290 0.43172967 0.37716049 0.34207465 [13] 0.31393111 0.26516556 0.19850174 0.12824752 0.07227036 0.04219880 [19] 0.02276121 -0.01081550 -0.05595183 -0.10360808 -0.15065647 -0.18137434 [25] -0.20269403 -0.22854536 -0.26484277 -0.31057574 -0.36095139 -0.39414587 [31] -0.40453124 -0.40485811 -0.39062512 -0.37478489 -0.36420192 -0.34759221 [37] -0.32927113 -0.30935654 -0.28415596 -0.26844110 -0.27230880 -0.27470474 [43] -0.27112278 -0.26120003 -0.24621842 -0.23338774 -0.22615046 -0.21568187 [49] -0.19616685 > (mypacf <- c(rpacf$acf)) [1] 0.949461628 -0.368075903 0.189450807 -0.026244597 0.179773351 [6] -0.228951481 -0.202938123 0.109679217 0.055975323 -0.114643232 [11] 0.154544022 -0.052827435 -0.152855045 -0.167946638 0.001345012 [16] 0.144129940 -0.007649849 -0.084504230 -0.045486868 0.027158539 [21] -0.075589966 -0.157221067 0.088439445 -0.023408949 -0.056913055 [26] -0.149723666 0.021556567 -0.070503293 0.003858715 -0.014734637 [31] 0.121683172 0.218475876 -0.088831352 -0.051899891 0.041872344 [36] -0.080521969 -0.015190688 -0.038710411 -0.004117093 -0.080087254 [41] 0.008244136 -0.044629670 0.005989269 -0.155008807 0.112030386 [46] -0.002822601 0.074571225 0.034415722 > 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/459ib1457705109.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/5jyhp1457705109.tab") > > try(system("convert tmp/1nu2x1457705109.ps tmp/1nu2x1457705109.png",intern=TRUE)) character(0) > try(system("convert tmp/2qz4x1457705109.ps tmp/2qz4x1457705109.png",intern=TRUE)) character(0) > try(system("convert tmp/3gj0c1457705109.ps tmp/3gj0c1457705109.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.179 0.195 1.381