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(101.1,101.35,101.45,101.49,101.68,101.92,102.04,102.55,104.02,105.41,105.48,105.54,105.16,105.16,105.16,105.16,105.16,105.17,105.17,105.54,106.9,107.27,107.31,107.39,107.41,107.46,113.14,117,119.28,119.39,119.5,119.67,119.67,119.73,119.77,119.77,119.78,119.78,119.78,121.28,122.44,122.72,122.75,122.8,122.81,122.83,122.83,122.83,122.84,122.85,123.61,124.74,125.1,125.29,125.45,125.51,125.55,125.57,125.81,127.41,127.75,127.76,127.8,128.23,130.01,130.07,130.17,130.21,130.22,130.23,130.23,130.23,130.23,130.24,130.13,130.14,130.79,131.38,131.61,131.72,131.89,131.89,131.96,131.99,132,132.06,132.11,132.88,135.48,136.56,136.96,137.4,138.32,138.82,138.96,138.94,139,139.19,139.22,139.37,140.74,141.17,141.51,142.94,144.81,145.41,146.11,146.23) > 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/13sbr1413643589.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/2tkgi1413643589.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/34d4b1413643589.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.967591912 0.932550945 0.897144540 0.861941751 [6] 0.828817593 0.797234662 0.765436400 0.734147379 0.706007576 [11] 0.679497926 0.652713497 0.625299265 0.595976662 0.565127202 [16] 0.533636641 0.502239530 0.471498391 0.440473629 0.408822529 [21] 0.377982658 0.351635772 0.326423367 0.300947196 0.274957365 [26] 0.247782308 0.219621069 0.198426988 0.181874408 0.168078290 [31] 0.154081358 0.140041697 0.126306991 0.112633434 0.098169109 [36] 0.083285417 0.068163172 0.052328011 0.035462541 0.017541212 [41] 0.001089327 -0.014326663 -0.029789828 -0.045507824 -0.061457722 [46] -0.075468301 -0.089231355 -0.103156571 -0.117284607 > (mypacf <- c(rpacf$acf)) [1] 0.9675919120 -0.0577607048 -0.0222580089 -0.0150753347 0.0135800580 [6] 0.0035529423 -0.0231491562 -0.0097948663 0.0320125445 0.0063853584 [11] -0.0227149974 -0.0259211682 -0.0429278294 -0.0366814299 -0.0275427909 [16] -0.0184921327 -0.0098453917 -0.0262319264 -0.0322719967 -0.0100561499 [21] 0.0458406786 -0.0103757578 -0.0282961604 -0.0272785928 -0.0321747586 [26] -0.0317886637 0.0883190311 0.0482486034 0.0268592968 -0.0196079746 [31] -0.0110061316 -0.0042061131 -0.0158770363 -0.0318605150 -0.0139527862 [36] -0.0067549598 -0.0194985084 -0.0343508496 -0.0424827547 -0.0008444533 [41] -0.0065544343 -0.0253704148 -0.0257194739 -0.0243305670 0.0074218424 [46] -0.0205908319 -0.0097846790 -0.0082803854 > 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/4ztiq1413643589.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/5tdab1413643589.tab") > > try(system("convert tmp/13sbr1413643589.ps tmp/13sbr1413643589.png",intern=TRUE)) character(0) > try(system("convert tmp/2tkgi1413643589.ps tmp/2tkgi1413643589.png",intern=TRUE)) character(0) > try(system("convert tmp/34d4b1413643589.ps tmp/34d4b1413643589.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.172 0.179 1.360