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(92.09,93.77,94.44,94.91,94.78,94.51,94.36,96.6,96.72,96.71,97.44,97.83,98.92,97.98,98.76,99.76,99.87,100.09,100.07,99.46,100.4,101.25,102.29,102.1,105.91,108.95,110.07,109.92,109.87,110.54,110.79,110.32,110.76,110.24,110.27,110.11,110.39,111.05,110.85,110.24,108.7,109.93,109.53,109.83,107.86,104.61,103.61,103.11,102.59,102.91,101.94,101.8,102.25,102.6,102.49,102.13,100.76,100.86,101.12,100.74,99.99,99.39,99.52,99.21,99.38,99.37,99.38,99.26,99.36,99.2,98.53,98.65,99.15,100.17,99.98,100.07,99.94,100.05,99.13,98.74,98.64,98.44,98.81,98.88,99.63,100.08,100.07,100.55,99.98,99.89,99.86,99.61,100.12,100.24,100.1,99.86,97.99,97.57,98.28,97.97,97.99,97.84,97.33,96.7,96.79,96.76,96.23,96.29,96.46,97.23,97.59,97.13,97.37,96.12,96.96,96.7,97,97.15,96.51,96.68) > 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/1664s1458035630.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/2h3mn1458035630.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/3kmfg1458035630.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.96624722 0.92828970 0.88903971 0.84917300 0.80498152 [7] 0.75277323 0.69573466 0.64722439 0.59754729 0.54693858 0.49301100 [13] 0.43545032 0.37890897 0.31763283 0.25701108 0.19881537 0.14026538 [19] 0.07730045 0.01460845 -0.04759179 -0.09989050 -0.14462607 -0.18696821 [25] -0.22945153 -0.25417795 -0.26856121 -0.27677726 -0.28618800 -0.29431250 [31] -0.29836358 -0.29857778 -0.29735223 -0.29214645 -0.28729605 -0.28195800 [37] -0.27564723 -0.26811006 -0.25545870 -0.23917271 -0.22135472 -0.20839981 [43] -0.19004112 -0.16981169 -0.14731916 -0.12784746 -0.11701252 -0.10928909 [49] -0.10490611 > (mypacf <- c(rpacf$acf)) [1] 0.9662472223 -0.0805227003 -0.0354620350 -0.0280594476 -0.0860389653 [6] -0.1396231589 -0.0918034421 0.1080181575 -0.0554917289 -0.0344863001 [11] -0.0638175617 -0.0896210332 -0.0425547183 -0.1316519709 -0.0036483181 [16] -0.0012683925 -0.0453405134 -0.1231725069 -0.0522225804 -0.0501728234 [21] 0.0609575786 0.0711388547 0.0040321985 -0.0497702337 0.2116956537 [26] 0.0734302060 0.0187715954 -0.0339989122 0.0008085259 -0.0141395352 [31] -0.0374613657 0.0118987500 0.0462937177 -0.0462480333 -0.0706318880 [36] -0.0546154159 -0.0181866483 -0.0164912469 0.0121252677 0.0235379502 [41] -0.1018734661 0.0457413153 -0.0169570653 -0.0119367069 -0.0013894469 [46] -0.0738238562 -0.0033025671 -0.1173978707 > 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/4vvj01458035630.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/523y61458035630.tab") > > try(system("convert tmp/1664s1458035630.ps tmp/1664s1458035630.png",intern=TRUE)) character(0) > try(system("convert tmp/2h3mn1458035630.ps tmp/2h3mn1458035630.png",intern=TRUE)) character(0) > try(system("convert tmp/3kmfg1458035630.ps tmp/3kmfg1458035630.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.129 0.232 1.365