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(473,475,552,530,525,548,487,483,550,528,560,546,521,507,596,520,590,568,503,515,529,573,590,529,524,516,598,532,582,573,535,538,554,590,607,529,563,562,593,588,576,558,543,494,585,586,553,541,506,500,570,541,544,545,552,460,526,569,549,525,473,498,582,573,528,571,518,483,551,562,580,515,492,509,601,579,561,537,513,499,563,561,546,558,507,517,544,529,557,532,512,488,518,567,537,484,487,484,534,514,523,489,495,468,513,544,520,509) > 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/1c4qb1425543463.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/22f061425543463.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/37kic1425543463.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.300577285 -0.043504134 -0.073752675 0.047841452 [6] 0.344366098 0.545245507 0.235303319 0.029987088 -0.167540144 [11] -0.142173573 0.199854467 0.559541211 0.114722654 -0.193784925 [16] -0.262413617 -0.111740706 0.135190777 0.336159740 0.051591864 [21] -0.114497168 -0.324647558 -0.225811462 0.113790761 0.346133269 [26] 0.047861911 -0.228288341 -0.359929729 -0.085983132 0.055723475 [31] 0.210545568 0.077262069 -0.177001664 -0.322970790 -0.149089458 [36] 0.079023489 0.314127313 0.077051363 -0.256853683 -0.227632803 [41] -0.003294659 0.076051903 0.240798308 0.099371089 -0.124547875 [46] -0.200528280 -0.030853357 0.071602461 0.280626026 > (mypacf <- c(rpacf$acf)) [1] 0.3005772849 -0.1471448945 -0.0163196375 0.0807482429 0.3305091703 [6] 0.4327780561 0.0858708471 0.1090010071 -0.2113513408 -0.2984008863 [11] -0.1156291752 0.3418331292 -0.1631909920 -0.1469762928 -0.0661923581 [16] 0.0151940834 -0.0892097321 0.1095737556 0.0277562157 0.0644005252 [21] -0.1060887270 0.0173829840 -0.0062820827 -0.0005378117 0.0239663396 [26] -0.0304814287 -0.1193582115 0.1323399212 -0.1334591238 -0.0516270417 [31] 0.0936015336 -0.0445269471 -0.0021809525 0.0733797544 0.0231395105 [36] 0.0466741836 0.0231470984 -0.1068617822 0.1660261981 0.0005036557 [41] -0.0343599523 -0.0047181128 -0.0505392622 -0.0024887112 0.0270929526 [46] 0.0344390290 -0.0928077453 -0.0838004437 > 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/4heqm1425543463.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/5hjsm1425543463.tab") > > try(system("convert tmp/1c4qb1425543463.ps tmp/1c4qb1425543463.png",intern=TRUE)) character(0) > try(system("convert tmp/22f061425543463.ps tmp/22f061425543463.png",intern=TRUE)) character(0) > try(system("convert tmp/37kic1425543463.ps tmp/37kic1425543463.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.152 0.219 1.366