R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(1.8,1.8,1.81,1.81,1.81,1.81,1.81,1.81,1.82,1.82,1.81,1.8,1.8,1.81,1.81,1.81,1.81,1.81,1.81,1.82,1.82,1.82,1.83,1.83,1.83,1.84,1.85,1.86,1.86,1.87,1.87,1.86,1.88,1.89,1.91,1.91,1.91,1.91,1.92,1.93,1.93,1.94,1.94,1.95,1.95,1.96,1.97,1.97,1.97,1.97,1.98,1.98,1.99,1.99,1.99,2,2,2.01,2.01,2.02,2.01,2.01,2.03,2.03,2.04,2.05,2.05,2.06,2.06,2.06,2.04,2.04,2.04,2.03,2.03,2.03,2.03,2.03,2.03,2.03,2.03,2.03,2.02,2.03,2.03,2.02,2.03,2.04,2.05,2.05,2.05,2.05,2.07,2.07,2.08,2.08) > 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/1i0bm1413732028.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/25sn91413732028.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/3oy2k1413732028.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.0280539311 0.0453030725 0.0225401467 0.0330664625 [6] 0.1778520375 0.0503712986 0.1951568737 -0.1503573749 0.0843752901 [11] -0.0012183236 -0.0153833658 0.1503457718 -0.0066764133 0.0062749466 [16] -0.1840364801 0.0026362202 -0.0620138309 -0.1266638819 0.0452380952 [21] -0.0403555184 0.0625429314 -0.1844263436 -0.0877007333 -0.0057458461 [26] 0.0823818806 -0.0093845725 -0.1097489093 -0.0696811473 -0.0800983941 [31] 0.1694049940 -0.0837371206 -0.0670379653 0.0839204493 -0.1654738699 [36] 0.0002552678 -0.1333983106 0.0594472292 -0.0828042328 -0.0722779170 [41] 0.0096769702 -0.1682887775 0.0812146106 -0.0400932888 -0.0985705003 [46] -0.0523298988 -0.0418035830 -0.0645665089 -0.1082729973 > (mypacf <- c(rpacf$acf)) [1] -0.028053931 0.044551112 0.025073749 0.032460753 0.178342780 [6] 0.060285693 0.190591531 -0.155578970 0.054617036 -0.039587339 [11] -0.046975010 0.094863269 0.028818599 -0.036608307 -0.151489221 [16] -0.056493322 -0.081638079 -0.158087047 0.008380276 0.072440500 [21] 0.119322059 -0.106218685 -0.094132003 0.016495856 0.120384374 [26] -0.059383863 -0.007802321 -0.046066141 -0.002692119 0.155466789 [31] -0.111855909 -0.130108121 0.090229184 -0.141623896 -0.014427542 [36] -0.157556091 -0.024378182 -0.017899915 -0.046583726 -0.012800408 [41] -0.087641415 0.013819892 0.113838125 -0.158850127 -0.047726379 [46] -0.055776867 -0.025463873 0.059463356 > 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/4v80v1413732028.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/5ntpd1413732028.tab") > > try(system("convert tmp/1i0bm1413732028.ps tmp/1i0bm1413732028.png",intern=TRUE)) character(0) > try(system("convert tmp/25sn91413732028.ps tmp/25sn91413732028.png",intern=TRUE)) character(0) > try(system("convert tmp/3oy2k1413732028.ps tmp/3oy2k1413732028.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.172 0.208 1.396