R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-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(6,6.7,-0.6,5.8,16.4,1.5,5.1,14.7,4.3,1.5,9.1,4.3,5.7,13,14.5,9.7,-4.7,7.3,5.2,-2.5,11.5,4.9,-2.4,-0.3,4.4,7.9,-9.7,-4.1,16.4,-4.9,3.5,3.8,-0.2,3.1,0.7,-2.8,5.9,-5.3,-2.9,6.6,-8.1,1.3,6.9,-7.2,-1.9,4,-5.7,3.9,-7.6,-0.9,7.3,-3.7,-2.5,9.3,1.3,9.5,11.3,-1.7,8,-4.8,1.6,1.9,-0.9,5.5,1.7,-5.4,1.9,0.2,-13.3,-8.2,0.2,5.7,-1.2,-2.8,5.5,-17.3,1.4,-2.2,-8.6,-5,4.1,0.7,-4.2,-2.3) > 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/153qw1394716514.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/27p0t1394716514.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/32mv61394716514.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.491717901 -0.249312424 0.463408477 -0.262668924 [6] -0.005901571 0.073019692 -0.104392765 0.220711931 -0.222332116 [11] -0.010759155 0.394545428 -0.484023880 0.077017434 0.303477977 [16] -0.330945380 0.106955954 0.092442603 -0.079637055 0.051776115 [21] -0.150763313 0.146216104 0.083201164 -0.278915323 0.173870623 [26] 0.079475185 -0.189558644 0.144116249 -0.047707090 -0.026757551 [31] 0.076793193 -0.138461196 0.156306989 -0.023949330 -0.206495589 [36] 0.281490392 -0.094569188 -0.155803558 0.223033057 -0.103718554 [41] -0.035483679 0.057982120 -0.069315988 0.165891473 -0.101838486 [46] -0.141872345 0.284423357 -0.187702337 -0.053725979 > (mypacf <- c(rpacf$acf)) [1] -0.491717901 -0.647705315 -0.129677129 -0.230468014 -0.040093657 [6] -0.227167624 -0.292141705 0.034376367 -0.120057418 -0.161797531 [11] 0.309877219 0.025042736 -0.048563016 -0.106014350 -0.104050907 [16] -0.090044682 -0.100006658 0.027018543 -0.024734847 -0.169209310 [21] -0.134437404 -0.027455757 0.124002451 -0.002901927 -0.117466285 [26] -0.077566321 0.023218332 -0.062389918 -0.054588927 0.067228131 [31] -0.033531971 -0.047728556 -0.009983442 -0.114673329 0.035569072 [36] -0.025018715 -0.098782015 -0.091889490 -0.087073853 -0.118468889 [41] -0.189413376 -0.167503377 -0.015749757 0.119672129 0.034271662 [46] 0.019949731 -0.033864792 0.003378265 > 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/4dwuj1394716514.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/590ej1394716514.tab") > > try(system("convert tmp/153qw1394716514.ps tmp/153qw1394716514.png",intern=TRUE)) character(0) > try(system("convert tmp/27p0t1394716514.ps tmp/27p0t1394716514.png",intern=TRUE)) character(0) > try(system("convert tmp/32mv61394716514.ps tmp/32mv61394716514.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.692 0.552 3.284