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 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/fisher/rcomp/tmp/1r1jm1374852897.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/fisher/rcomp/tmp/2yxkk1374852897.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/fisher/rcomp/tmp/32ke31374852897.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.485867850 0.369157317 -0.347150962 0.329736926 [6] -0.278956160 0.228032238 -0.282850574 0.343521285 -0.279130504 [11] 0.303793382 -0.431845608 0.799242547 -0.432945206 0.322681266 [16] -0.307600382 0.273062104 -0.208086611 0.181441461 -0.279234016 [21] 0.294237408 -0.239190803 0.266011656 -0.356560889 0.619288316 [26] -0.379535273 0.294232546 -0.296073656 0.215248302 -0.168366900 [31] 0.118030932 -0.262855688 0.237786124 -0.208566366 0.238341179 [36] -0.294648235 0.435544585 -0.327912461 0.271022183 -0.271957840 [41] 0.154598289 -0.114894282 0.070454932 -0.195708225 0.156951461 [46] -0.168720101 0.186133568 -0.233442859 0.251584412 -0.262044723 [51] 0.231584621 -0.211091911 0.095233915 -0.064674200 -0.002257852 [56] -0.148881425 0.088660944 -0.127517233 0.180893765 -0.168151116 [61] 0.163448693 > (mypacf <- c(rpacf$acf)) [1] -0.485867850 0.174216650 -0.154426502 0.115229949 -0.041831653 [6] 0.005836621 -0.125226445 0.160910871 -0.012299756 0.094654580 [11] -0.242377078 0.707798165 0.178619217 -0.184464208 0.126786911 [16] -0.011430991 0.060699596 -0.018909185 -0.104703923 -0.090964652 [21] -0.078056277 0.055708233 0.075384392 -0.088479802 -0.062607529 [26] 0.079683207 -0.032334025 -0.066166228 -0.025705072 -0.138912520 [31] -0.077621074 -0.026442609 -0.027527440 -0.007626684 -0.023697748 [36] -0.131147825 -0.045153544 0.082801317 0.024189790 -0.099558979 [41] 0.026141304 0.047515107 0.097882578 -0.018081062 -0.008751162 [46] -0.052870440 -0.056919673 -0.098224950 -0.053899377 -0.037474920 [51] 0.007278001 -0.003074198 0.030695774 -0.071005179 -0.139143959 [56] 0.025755858 0.046601005 0.074537355 0.028895014 0.072059510 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/444gn1374852897.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/fisher/rcomp/tmp/5a42m1374852897.tab") > > try(system("convert tmp/1r1jm1374852897.ps tmp/1r1jm1374852897.png",intern=TRUE)) character(0) > try(system("convert tmp/2yxkk1374852897.ps tmp/2yxkk1374852897.png",intern=TRUE)) character(0) > try(system("convert tmp/32ke31374852897.ps tmp/32ke31374852897.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.884 0.373 2.237