R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" 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(203089,198480,192684,187827,182414,182510,211524,211451,200140,191568,186424,191987,203583,201920,195978,191395,188222,189422,214419,224325,216222,210506,207221,210027,215191,215177,211701,210176,205491,206996,235980,241292,236675,229127,225436,229570,239973,236168,230703,224790,217811,219576,245472,248511,242084,235572,229827,229697,239567,237201,233164,227755,220189,221270,245413,247826,237736,230079,225939,228987) > 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/19fme1476812092.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/2zn921476812092.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/3zxtk1476812092.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.861607054 0.660602815 0.553899827 0.553281050 [6] 0.616338204 0.643785757 0.567854593 0.451496303 0.381443328 [11] 0.396900525 0.491887829 0.545191861 0.419386641 0.237848435 [16] 0.120918680 0.083567862 0.101205016 0.100037121 0.035568582 [21] -0.054069231 -0.113732515 -0.107190320 -0.034623694 0.001468726 [26] -0.099994791 -0.231214934 -0.313629062 -0.334900254 -0.312103590 [31] -0.303145811 -0.326522365 -0.365853742 -0.386185484 -0.361171124 [36] -0.288724102 -0.235875002 -0.270284563 -0.328380457 -0.360457704 [41] -0.358461512 -0.331643147 -0.301512447 -0.282978501 -0.280368046 [46] -0.272598428 -0.244960407 -0.196279224 -0.156302811 > (mypacf <- c(rpacf$acf)) [1] 0.861607054 -0.317365442 0.334619248 0.184695894 0.250978617 [6] -0.029789862 -0.161356983 -0.005802893 0.019612734 0.116511465 [11] 0.238995493 -0.087979494 -0.483868966 0.020512673 -0.130797043 [16] -0.162818082 -0.112891908 -0.051363735 0.071366889 0.012997009 [21] 0.015077934 0.073872083 0.067294604 -0.063455495 -0.149700894 [26] 0.093572549 -0.112500823 -0.039821516 -0.052416226 -0.010590727 [31] 0.096458826 -0.060377720 0.051226208 -0.013303667 -0.006126418 [36] 0.072324534 0.057614772 0.013992208 -0.014720066 -0.018522052 [41] -0.059927352 0.042530898 -0.070751248 -0.055129119 0.010987054 [46] -0.095498502 -0.078892610 -0.007930252 > 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/4rxsm1476812092.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/5lobx1476812092.tab") > > try(system("convert tmp/19fme1476812092.ps tmp/19fme1476812092.png",intern=TRUE)) character(0) > try(system("convert tmp/2zn921476812092.ps tmp/2zn921476812092.png",intern=TRUE)) character(0) > try(system("convert tmp/3zxtk1476812092.ps tmp/3zxtk1476812092.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.132 0.105 1.256