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(1859000,1869000,1858000,1859000,1878000,1876000,1869000,1888000,1874000,1872000,1885000,1878000,1868000,1879000,1873000,1863000,1880000,1886000,1880000,1901000,1900000,1901000,1922000,1917000,1918000,1927000,1926000,1926000,1945000,1940000,1934000,1945000,1940000,1935000,1945000,1937000,1932000,1947000,1943000,1941000,1951000,1951000,1944000,1962000,1968000,1969000,1972000,1954000,1959000,1971000,1963000,1964000,1986000,1972000,1975000,1993000,1983000,1997000,2000000,1995000,1991000,2001000,1993000,1995000,2010000,2005000,2008000,2028000,2015000,2023000,2031000,2027000) > 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/1s5kp1476819611.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/2nl651476819611.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/364fr1476819611.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.9391413142 0.8953850585 0.8624094651 0.8025883213 [6] 0.7577592583 0.7332510476 0.6788923123 0.6421086858 0.6181108939 [11] 0.5687969516 0.5330731401 0.5092089850 0.4520172711 0.4082740079 [16] 0.3720645252 0.3130458215 0.2692394520 0.2424290982 0.1921598996 [21] 0.1574266097 0.1380089751 0.0985291004 0.0758472607 0.0595403963 [26] 0.0264088932 0.0009782166 -0.0213930410 -0.0610863635 -0.0781975241 [31] -0.0860568039 -0.1156939495 -0.1289284025 -0.1376377615 -0.1655110237 [36] -0.1798399382 -0.1909640418 -0.2205578791 -0.2365850959 -0.2507939847 [41] -0.2813362728 -0.3002335896 -0.3145359005 -0.3457927748 -0.3612000649 [46] -0.3652457434 -0.3819095916 -0.3870887091 -0.3976968257 > (mypacf <- c(rpacf$acf)) [1] 0.939141314 0.113534808 0.088948072 -0.221167639 0.050280120 [6] 0.147676210 -0.184920277 0.063995422 0.044388971 -0.114424726 [11] 0.023034852 0.019578284 -0.179374470 -0.009029007 -0.032381100 [16] -0.077732010 0.007700747 0.052422051 -0.068393528 0.002164728 [21] 0.047218974 -0.030538576 0.043659157 -0.042755650 0.004677938 [26] -0.045032375 -0.066369943 -0.032155415 0.092425134 0.026434728 [31] -0.091134999 0.005460690 -0.026515030 -0.043560216 -0.028717014 [36] -0.036056025 -0.050114139 -0.009774199 -0.038420205 -0.033379233 [41] -0.060731823 -0.021506577 -0.059884927 -0.017708788 0.076990606 [46] 0.006608319 -0.030287050 -0.138642676 > 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/493aw1476819611.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/5rnn81476819611.tab") > > try(system("convert tmp/1s5kp1476819611.ps tmp/1s5kp1476819611.png",intern=TRUE)) character(0) > try(system("convert tmp/2nl651476819611.ps tmp/2nl651476819611.png",intern=TRUE)) character(0) > try(system("convert tmp/364fr1476819611.ps tmp/364fr1476819611.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.369 0.126 1.532