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(86.5,86.6,98.8,84.4,91.4,95.7,78.5,81.7,94.3,98.5,95.4,91.7,92.8,90.6,102.2,91.8,95,102,88.9,89.6,97.9,108.6,100.8,95.1,101,100.9,102.5,105.4,98.4,105.3,96.5,88.1,107.9,107.1,92.5,95.7,85.2,85.5,94.7,86.2,88.8,93.4,83.4,82.9,96.7,96.2,92.8,92.8,90.2,95.9,107.5,98,95,108.5,91.8,91.7,108.3,105.1,104.8,103.2,98.6,102.4,121.2,102.6,108.9,105.5,90.8,99.6,111.6,104.7,103.1,101.7,98.8,101.4,114.2,96.9,98.3,104.8,94.4,94.5,102.4,105.5,101.2,99.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/16ufa1384333569.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/22bj21384333569.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/3485o1384333569.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.3968049323 0.1821979477 0.4451503204 0.2389309312 [6] 0.3164259869 0.4959720017 0.1975731766 0.0996000755 0.1462589032 [11] -0.0932496861 0.0718255336 0.3772378388 -0.0426598792 -0.2455806008 [16] -0.0654158011 -0.1650574454 -0.0926061668 0.0542376095 -0.1593247845 [21] -0.1984440289 -0.1411941196 -0.3120215958 -0.0849389604 0.1471061261 [26] -0.1503644536 -0.2476600872 -0.0714217157 -0.0758726856 0.0426801767 [31] 0.1601354098 -0.0006166162 0.0151770161 0.0737407895 -0.0338784203 [36] 0.1513996507 0.3166460222 0.0752208997 -0.0113596912 0.0952567422 [41] 0.0514796114 0.1328531564 0.1428230708 -0.0217976528 -0.0376970955 [46] -0.0012092558 -0.0997723785 0.0086708984 0.1352190737 > (mypacf <- c(rpacf$acf)) [1] 0.3968049323 0.0293678896 0.4315928836 -0.1068589248 0.3549363614 [6] 0.1682946584 -0.0763975916 -0.1197356492 -0.1923991782 -0.3449292173 [11] 0.0691409154 0.3590947622 -0.1525794758 -0.2285306250 -0.1383985402 [16] 0.0363343661 0.0209203310 0.0203903899 0.0177902071 0.0709381614 [21] 0.0188391045 -0.1187373739 0.0480151061 0.0093124101 0.0350838219 [26] -0.0295877573 0.0795953190 0.0952011523 0.0928658517 0.0261184389 [31] -0.0453472619 0.0079527104 0.0034657751 0.0114585612 -0.0679631582 [36] -0.0009126034 0.0143272374 0.0178224708 -0.0457839736 -0.1217260441 [41] -0.0325661800 -0.1143177796 0.0095387886 -0.0892496579 0.1499598238 [46] 0.0354288644 0.0606449928 0.0393433569 > 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/4lu541384333569.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/59mom1384333569.tab") > > try(system("convert tmp/16ufa1384333569.ps tmp/16ufa1384333569.png",intern=TRUE)) character(0) > try(system("convert tmp/22bj21384333569.ps tmp/22bj21384333569.png",intern=TRUE)) character(0) > try(system("convert tmp/3485o1384333569.ps tmp/3485o1384333569.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.128 0.457 2.562