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(4.53,4.53,4.53,4.61,4.63,4.63,4.63,4.63,4.63,4.63,4.63,4.63,4.63,4.63,4.66,4.7,4.72,4.73,4.73,4.74,4.74,4.74,4.76,4.88,4.88,4.88,4.88,4.89,4.97,4.97,4.97,4.97,4.97,4.97,4.97,4.97,4.97,4.97,4.97,4.98,5,5.03,5.04,5.04,5.05,5.05,5.05,5.06,5.06,5.06,5.07,5.09,5.18,5.23,5.25,5.26,5.28,5.29,5.29,5.29,5.29,5.3,5.3,5.3,5.32,5.33,5.33,5.37,5.45,5.47,5.5,5.51) > 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/1w38k1413748331.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/27w0r1413748331.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/3bt4u1413748331.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.948512211 0.893825002 0.840253427 0.793980408 [6] 0.755992669 0.719473342 0.681865437 0.644266552 0.607201344 [11] 0.568761093 0.529576025 0.489177714 0.445781043 0.399672478 [16] 0.354071597 0.310983674 0.269098915 0.227386036 0.185996760 [21] 0.148959669 0.118936259 0.090458714 0.064340282 0.047700744 [26] 0.028444802 0.007459976 -0.014766211 -0.037497959 -0.053895060 [31] -0.073118642 -0.093116216 -0.110852288 -0.126985203 -0.142994512 [36] -0.159500365 -0.176445468 -0.194593735 -0.214422612 -0.236008490 [41] -0.258061734 -0.280037527 -0.300779917 -0.321684108 -0.342932061 [46] -0.356267672 -0.370644646 -0.385919219 -0.401431984 > (mypacf <- c(rpacf$acf)) [1] 0.9485122105 -0.0583148284 -0.0167799443 0.0432107660 0.0527445276 [6] -0.0110169941 -0.0276176777 -0.0114298105 -0.0103552134 -0.0365734868 [11] -0.0314893932 -0.0356844050 -0.0568271134 -0.0585129490 -0.0293059043 [16] -0.0139286809 -0.0304015014 -0.0366292523 -0.0280343343 0.0133102286 [21] 0.0371250228 -0.0153991844 0.0036915187 0.0859606188 -0.0379511897 [26] -0.0307444519 -0.0190613916 -0.0174905919 0.0331268697 -0.0643396874 [31] -0.0341034124 0.0005686071 -0.0182707622 -0.0381417068 -0.0345719722 [36] -0.0289760591 -0.0416726089 -0.0495345164 -0.0448975297 -0.0339249753 [41] -0.0383410342 -0.0291250809 -0.0290558313 -0.0282194509 0.0414926142 [46] -0.0459780887 -0.0315426619 -0.0243256529 > 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/4mymz1413748331.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/5zvnm1413748331.tab") > > try(system("convert tmp/1w38k1413748331.ps tmp/1w38k1413748331.png",intern=TRUE)) character(0) > try(system("convert tmp/27w0r1413748331.ps tmp/27w0r1413748331.png",intern=TRUE)) character(0) > try(system("convert tmp/3bt4u1413748331.ps tmp/3bt4u1413748331.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.202 0.192 1.406