R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-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(1516,1289,1428,1335,1402,1475,1582,1317,1450,1497,1556,981,1807,1573,1756,1708,1737,1679,1872,1598,1747,1882,1369,865,1432,1172,1268,1120,1235,1272,1360,1069,1434,1552,1584,1070,1676,1690,1643,1446,1566,1352,1805,1613,1824,1866,1774,1505,1972,1856,2037,1888,2167,2191,2036,2103,2131,2039,1983,1629,2032,2216,2141,2073,2145,2429,2157,1994,2116,2287,2162,1699) > 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.291 () > #Author: root > #To cite this work: Wessa P., (2012), (Partial) Autocorrelation Function (v1.0.11) 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) > 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/1oidj1394805451.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/28za21394805451.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/3qhi51394805451.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.713465627 0.672358153 0.632281932 0.672415431 [6] 0.510456661 0.498438555 0.390444725 0.460657783 0.322558596 [11] 0.276967678 0.214604391 0.363443735 0.202106310 0.173883346 [16] 0.161730007 0.226129173 0.097570578 0.119461024 0.055019107 [21] 0.079759376 -0.006343004 -0.019264233 -0.076767821 0.020880112 [26] -0.124323654 -0.154312543 -0.161412663 -0.117313733 -0.215930985 [31] -0.194928740 -0.201402371 -0.153769431 -0.221625290 -0.224999786 [36] -0.244861583 -0.168886191 -0.243061005 -0.264525712 -0.268737595 [41] -0.213487487 -0.260469994 -0.265495502 -0.226876105 -0.181721276 [46] -0.187971430 -0.168556048 -0.159519067 -0.090577043 > (mypacf <- c(rpacf$acf)) [1] 7.134656e-01 3.326599e-01 1.713434e-01 2.745234e-01 -2.261376e-01 [6] 1.165035e-02 -1.818457e-01 2.065603e-01 -1.378189e-01 -8.621028e-02 [11] -2.386059e-05 3.401953e-01 -1.830115e-01 -8.386153e-02 7.458904e-02 [16] -2.402818e-02 -9.580928e-02 2.476199e-02 -5.221229e-03 -1.903406e-01 [21] 8.176164e-03 4.551452e-02 5.124711e-03 2.525252e-02 -1.614860e-01 [26] -4.607453e-02 -8.668588e-03 -8.978978e-03 2.410872e-02 -4.232388e-02 [31] 6.592778e-02 3.010335e-02 -3.080925e-02 -9.444184e-02 -1.632603e-02 [36] -4.879835e-02 -2.597958e-03 -5.449758e-03 -6.840144e-02 -8.956740e-04 [41] 9.966788e-02 -4.033931e-02 1.212840e-01 -1.147163e-02 5.132105e-02 [46] -8.594066e-03 -3.094714e-02 -5.112715e-03 > 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/4rcnk1394805451.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/5d0ei1394805451.tab") > > try(system("convert tmp/1oidj1394805451.ps tmp/1oidj1394805451.png",intern=TRUE)) character(0) > try(system("convert tmp/28za21394805451.ps tmp/28za21394805451.png",intern=TRUE)) character(0) > try(system("convert tmp/3qhi51394805451.ps tmp/3qhi51394805451.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.242 0.475 2.769