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(55.7,59.2,59.8,61.6,65.8,64.2,67,62.8,65.5,75.2,80.9,83.2,83.7,86.4,85.9,80.4,81.8,87.5,83.7,87,99.7,101.4,101.9,115.7,123.2,136.9,146.8,149.6,146.5,157,147.9,133.6,128.7,100.8,91.8,89.3,96.7,91.6,93.3,93.3,101,100.4,86.9,83.9,80.3,87.7,92.7,95.5,92,87.4,86.8,83.7,85,81.7,90.9,101.5,113.8,120.1,122.1,132.5,140,149.4,144.3,154.4,151.4,145.5,136.8,146.6,145.1,133.6,131.4,127.5,130.1,131.1,132.3,128.6,125.1,128.7,156.1,163.2,159.8,157.4,156.2,152.5) > 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/171wq1387020443.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/2bxjq1387020443.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/3og531387020443.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.938290504 0.856343025 0.764851386 0.667183359 [6] 0.564636482 0.466507365 0.387276147 0.312185769 0.250244679 [11] 0.195570315 0.154309751 0.110647094 0.076222279 0.052404695 [16] 0.033026783 -0.001596013 -0.041342842 -0.073478879 -0.119303133 [21] -0.168396694 -0.214596898 -0.250808561 -0.285372411 -0.302322670 [26] -0.300678008 -0.274360403 -0.231710431 -0.182470330 -0.122746992 [31] -0.045031306 0.036912420 0.100200650 0.151551356 0.176332551 [36] 0.188226396 0.188896294 0.187988896 0.180567018 0.165908964 [41] 0.153836417 0.146212141 0.138275253 0.111585708 0.081943726 [46] 0.057589067 0.050859294 0.053640923 0.057294441 > (mypacf <- c(rpacf$acf)) [1] 0.938290504 -0.201035519 -0.100622824 -0.086312815 -0.086564018 [6] -0.013282778 0.093909795 -0.067117241 0.037139421 -0.032498744 [11] 0.035048478 -0.098874331 0.048859061 0.024378027 -0.004461298 [16] -0.185956310 -0.034348698 0.021881633 -0.140999805 -0.035968337 [21] 0.002264124 -0.009960249 -0.040015860 0.099558736 0.041929555 [26] 0.139099777 0.075881830 0.006062249 0.018094143 0.211778017 [31] 0.064958319 -0.108063016 -0.053289316 -0.113997521 0.003539801 [36] 0.002213255 0.069999251 -0.016078576 -0.045529935 -0.018873571 [41] 0.022683868 -0.069230530 -0.137865308 -0.066839923 -0.027227152 [46] 0.128170161 0.149263853 -0.043090750 > 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/4t3c11387020443.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/5maiw1387020443.tab") > > try(system("convert tmp/171wq1387020443.ps tmp/171wq1387020443.png",intern=TRUE)) character(0) > try(system("convert tmp/2bxjq1387020443.ps tmp/2bxjq1387020443.png",intern=TRUE)) character(0) > try(system("convert tmp/3og531387020443.ps tmp/3og531387020443.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.522 0.735 4.218