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(-23.50,5.90,8.40,7.80,4.80,3.50,8.70,6.80,6.00,3.60,8.70,8.90,8.10,7.00,7.90,8.00,7.50,6.30,7.60,8.40,6.80,8.80,8.70,8.70,7.40,2.80,4.80,-21.10,8.50,9.40,1.80,4.80,5.80,3.30,-9.00,-6.00,-0.90,-17.30,-9.20,-8.10,-20.90,-14.60,-13.90,-20.80,-16.10,-5.00,-7.20,-9.70,-1.40,0.20,2.60,-4.80,-6.20,-2.00,-0.80,-3.10,0.60,0.20,0.30,-0.10,4.30,-3.20,-1.30,1.50,2.50,-2.20,1.70,5.70,2.70,-4.80,-3.10,-0.50,-3.40,-4.70,-5.60,-1.70,-1.80,-5.40,-4.80,-2.80,-4.90,-6.80,-7.60,-6.60,-5.60,-1.40,0.10,-3.70,-5.60,-3.10,-3.80,-5.10,-4.10,-0.30,-0.30,-2.40) > 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/1gqu31430160274.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/2npuq1430160274.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/3ovpi1430160274.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.280781215 -0.181445020 0.174273180 0.017592628 [6] -0.073285446 -0.081018677 0.144907491 -0.057800340 -0.078027194 [11] 0.218899666 -0.131599672 -0.076594476 0.104291797 -0.015576822 [16] -0.049348086 -0.022467700 0.050959560 0.052892918 -0.050332254 [21] 0.003348511 -0.045255722 0.110792565 -0.120370975 -0.083338450 [26] 0.058284610 -0.157498880 0.180652049 0.029544944 -0.070878878 [31] 0.020224902 0.020487980 0.014936084 -0.204337933 0.074030131 [36] 0.086601624 -0.125084297 0.007915328 0.056559904 -0.063577644 [41] 0.028926942 -0.066683669 -0.014935706 0.057252408 0.082804013 [46] -0.032924629 -0.038172091 0.123444694 0.009164996 > (mypacf <- c(rpacf$acf)) [1] -0.2807812148 -0.2825595672 0.0349144123 0.0465967512 0.0001702419 [6] -0.1215768924 0.0629536212 -0.0239603608 -0.0410107586 0.1752312496 [11] -0.0459301526 -0.0617216624 0.0060539751 -0.0152802140 -0.0074327669 [16] -0.0221268190 -0.0362116930 0.0840818026 0.0400231063 -0.0333586133 [21] -0.0665918940 0.1076465767 -0.1065330908 -0.1084165134 -0.0740693155 [26] -0.2355029679 0.1270689194 0.0930261873 0.0236255264 0.0253571329 [31] 0.0037852967 -0.0527374573 -0.1341857259 -0.0391870989 -0.0402229336 [36] -0.0071253080 -0.0914786348 -0.0438108478 -0.0325663813 0.0291570368 [41] -0.0978559016 -0.0504308686 0.0913828580 0.1285899510 0.0132575444 [46] -0.0003458138 0.0572753345 0.0833537320 > 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/4kg9t1430160274.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/5rot51430160274.tab") > > try(system("convert tmp/1gqu31430160274.ps tmp/1gqu31430160274.png",intern=TRUE)) character(0) > try(system("convert tmp/2npuq1430160274.ps tmp/2npuq1430160274.png",intern=TRUE)) character(0) > try(system("convert tmp/3ovpi1430160274.ps tmp/3ovpi1430160274.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.182 0.202 3.946