R version 3.0.1 (2013-05-16) -- "Good Sport" 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(2240,2240,2380,2380,2380,2380,2140,2400,2180,2260,2280,2480,2360,2160,2380,2280,2320,2400,1960,2520,2200,2420,2300,2280,2220,2240,2200,2340,2240,2500,1820,2520,2180,2480,2260,2400,2240,2240,2240,2140,2200,2460,1860,2480,1960,2540,2280,2320,2320,2440,2320,2180,2120,2460,2140,2480,2100,2700,2200,2260,2340,2720,2300,2360,2020,2380,2000,2540,1980,2940,2260,2300,2300,2820,2380,2360,1980,2340,2160,2700,1920,2980,2240,2180,2440,2740,2360,2380,2000,2500,2180,2740,1960,3060,2300,2240,2580,2740,2260,2400,1820,2440,2080,2680,1900,3000,2240,2300) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > par2 <- '1' > par1 <- '60' > #'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/1r3yc1374853903.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/2kfqx1374853903.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/3bom21374853903.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.00000000 -0.78814997 0.53069672 -0.47056202 0.43388619 -0.37643499 [7] 0.34205430 -0.38251144 0.42027824 -0.40568581 0.44465339 -0.66140327 [13] 0.82823171 -0.67004801 0.46864209 -0.40967550 0.35873549 -0.29352877 [19] 0.28461702 -0.34624084 0.37168641 -0.34866288 0.37963400 -0.53863312 [25] 0.66413152 -0.56290324 0.42638891 -0.37170147 0.30190627 -0.22510837 [31] 0.22172625 -0.29401389 0.31776106 -0.29929500 0.32946776 -0.42533538 [37] 0.50209486 -0.45870897 0.38536673 -0.32821247 0.23538480 -0.15266723 [43] 0.14973985 -0.20594737 0.22641690 -0.22648773 0.26008663 -0.30488917 [49] 0.33608709 -0.33861684 0.31534659 -0.25364874 0.15720544 -0.07374055 [55] 0.06933099 -0.12822356 0.15106445 -0.17361213 0.21917557 -0.22903416 [61] 0.24543640 > (mypacf <- c(rpacf$acf)) [1] -0.7881499727 -0.2388568362 -0.3937272036 -0.1635432062 -0.1782045543 [6] -0.0431255077 -0.2979102106 -0.0945516776 -0.1834023304 0.1499074072 [11] -0.7309966768 -0.1542070230 0.2009082775 -0.1187265341 0.0256261956 [16] -0.0512206425 0.0302070953 0.1045962028 0.0748641594 0.0601474160 [21] -0.0705056790 -0.0800209594 0.0684998303 0.0190374237 -0.1093993157 [26] 0.0009592023 0.0246468010 -0.0179334032 0.0857875091 0.0148074904 [31] -0.0369830314 -0.0283803141 -0.0479909614 -0.0340995045 0.0820324603 [36] -0.0002021211 -0.1276533497 -0.0502148570 0.0678985344 -0.0681837160 [41] -0.0753564345 -0.1074085749 0.0077916993 -0.0271584406 0.0087131795 [46] 0.0203615299 0.0507090841 -0.0014765537 -0.0111339865 -0.0540722470 [51] -0.0268689576 -0.0440359977 0.0519055916 0.1077040507 -0.0620798287 [56] -0.0603112572 -0.0655060281 -0.0255594322 -0.0696075712 0.0689114622 > 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/4zbub1374853903.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/5bmp51374853903.tab") > > try(system("convert tmp/1r3yc1374853903.ps tmp/1r3yc1374853903.png",intern=TRUE)) character(0) > try(system("convert tmp/2kfqx1374853903.ps tmp/2kfqx1374853903.png",intern=TRUE)) character(0) > try(system("convert tmp/3bom21374853903.ps tmp/3bom21374853903.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.666 0.599 3.237