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(12.8,12.1,11.4,11.4,10.6,10.4,10.9,11.6,13.3,15.2,17.4,19.1,19.9,19.4,18.2,15.8,13.5,12.1,10.3,8.8,8.2,6.8,5.9,4.9,3.9,3.6,2.8,4,4.2,4.2,4.8,4,3.8,4,3.7,4,4.6,4.6,4.6,4.5,4.1,4.1,4.4,4.2,4.4,3.2,2.8,1.7,-0.2,-2.9,-5.2,-5.3,-4.8,-2.2,-0.8,-1.1,-1.5,-2,-2.8,-3.4,-4.1,-5.5,-8.6,-7.6,-8.6,-8.7,-4.6,-4.3,-1.5,1.2,1.8,0) > 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/14w1o1425590293.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/2rljw1425590293.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/3jqa71425590293.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.530529215 0.370583487 0.227099555 -0.155187508 [6] -0.215531964 -0.224767386 -0.260604842 -0.288661393 -0.163332739 [11] -0.099840059 -0.098760941 0.009458838 0.052213072 0.035777751 [16] 0.089407024 0.030233690 -0.030236081 -0.153831429 -0.136366843 [21] -0.170293819 -0.111264621 -0.024439481 -0.024968948 0.074764746 [26] 0.068373969 0.093074910 0.091922288 0.058398597 0.039904697 [31] 0.100125523 0.101676281 0.066618054 0.121453766 0.041471355 [36] -0.056048280 -0.010743322 -0.142558175 -0.135427496 -0.073635678 [41] -0.074964881 0.027368524 0.041242275 0.099831732 0.075205385 [46] 0.061839135 0.065833530 -0.020956888 -0.081779819 > (mypacf <- c(rpacf$acf)) [1] 0.530529215 0.124032613 -0.015439569 -0.426391909 -0.049143015 [6] 0.055870966 0.010322360 -0.271241851 0.028821665 0.075027399 [11] -0.059485090 -0.105812423 0.033532623 0.031287886 0.003587689 [16] -0.176948960 -0.048655509 -0.189834326 0.075067511 -0.093195305 [21] 0.084581110 -0.119032696 -0.030936146 0.015193774 -0.008649790 [26] -0.053491332 -0.040848771 -0.010604017 -0.007491053 0.141881108 [31] 0.034487366 -0.077014095 0.102363746 -0.020189541 -0.071652265 [36] -0.040509967 -0.110694024 0.082998839 0.024739444 0.030082905 [41] 0.041593744 0.006777295 0.038490161 0.028253473 -0.035473085 [46] -0.019156049 -0.046524844 -0.074664117 > 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/44d9v1425590293.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/5y76o1425590293.tab") > > try(system("convert tmp/14w1o1425590293.ps tmp/14w1o1425590293.png",intern=TRUE)) character(0) > try(system("convert tmp/2rljw1425590293.ps tmp/2rljw1425590293.png",intern=TRUE)) character(0) > try(system("convert tmp/3jqa71425590293.ps tmp/3jqa71425590293.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.209 0.239 1.452