R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(19.4,19.4,19.4,19.5,19.5,19.5,28.7,28.7,28.7,21.8,21.8,21.8,20,20,20,22.6,22.6,22.6,22.4,22.4,22.4,18.6,18.6,18.6,16.2,16.2,16.2,13.8,13.8,13.8,24.1,24.1,24.1,19.9,19.9,19.9,22.3,22.3,22.3,20.9,20.9,20.9,23.5,23.5,23.5,23.1,23.1,23.1,25.7,25.7,25.7,19.7,19.7,19.7,23.1,23.1,23.1,20.7,20.7,20.7,18,18,18,16.9,16.9,16.9,24.4,24.4,24.4,15.5,15.5,15.5,18.4,18.4,18.4,16.2,16.2,16.2,20.6,20.6,20.6,19.8,19.8,19.8) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1scwl1384333858.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/28sh21384333858.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/3d6071384333858.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.000000e+00 -3.586820e-06 -3.629520e-06 -5.183600e-01 -9.917131e-06 [6] -9.959831e-06 1.083989e-01 1.104548e-04 1.104121e-04 -1.919845e-01 [11] 2.969802e-05 2.965532e-05 3.094058e-01 3.931625e-05 3.927355e-05 [16] -2.350152e-01 -1.663174e-05 -1.667444e-05 1.805163e-01 4.792034e-05 [21] 4.787764e-05 -4.316966e-01 4.376775e-06 4.334074e-06 4.146171e-01 [26] -4.093885e-05 -4.098155e-05 -2.466464e-01 -8.359639e-05 -8.363909e-05 [31] 1.423569e-01 3.766161e-05 3.761891e-05 -1.846210e-01 -5.284155e-05 [36] -5.288425e-05 2.946130e-01 -8.668149e-06 -8.710849e-06 -2.274670e-01 [41] -2.474479e-05 -2.478749e-05 2.055485e-01 2.120067e-05 2.115797e-05 [46] -2.537831e-01 5.124029e-06 5.081328e-06 2.364085e-01 > (mypacf <- c(rpacf$acf)) [1] -3.586820e-06 -3.629533e-06 -5.183600e-01 -1.997931e-05 -2.008291e-05 [6] -2.191954e-01 1.342070e-04 1.340387e-04 -3.405802e-01 2.843720e-04 [11] 2.840458e-04 7.197079e-02 3.305549e-04 3.301200e-04 -5.333327e-02 [16] 3.330604e-04 3.325605e-04 9.726402e-02 2.484717e-04 2.479985e-04 [21] -4.279096e-01 3.908822e-04 3.902553e-04 -1.233282e-01 3.495078e-04 [26] 3.487960e-04 -2.264330e-01 5.894764e-04 5.883777e-04 -1.843019e-01 [31] 8.701203e-04 8.683981e-04 -1.469690e-01 1.152792e-03 1.150197e-03 [36] 1.992769e-02 9.871858e-04 9.846294e-04 -4.098849e-02 9.811008e-04 [41] 9.782674e-04 -6.926692e-02 8.929209e-04 8.900801e-04 -1.503155e-01 [46] 1.105151e-03 1.101636e-03 -1.919635e-01 > 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/4n11n1384333858.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/5t62u1384333858.tab") > > try(system("convert tmp/1scwl1384333858.ps tmp/1scwl1384333858.png",intern=TRUE)) character(0) > try(system("convert tmp/28sh21384333858.ps tmp/28sh21384333858.png",intern=TRUE)) character(0) > try(system("convert tmp/3d6071384333858.ps tmp/3d6071384333858.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.889 0.386 2.254