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(12374.6,12864.7,14905.8,12259.7,14088.9,14243.7,12732.8,11612,14176.6,14452.6,14512.7,12645.1,13820.5,13644.7,15684.1,13568.3,14531.1,15320.1,14344.2,12899.4,14462,16044.7,14731.2,12798.3,14213.1,14683.3,14652,15623.1,14880.4,15765.7,15433.1,12402.6,15639.8,14861.7,11699.4,10651.9,10086.9,10676.9,11332.1,10756.1,10450.5,11930.2,11419.9,9713.1,12608.5,12357.2,12107.9,11627.2,11105.9,11841.6,14290.8,13271.7,12909.4,14924.1,13257.4,12184.4,15035.5,14401,14165,13375.6,14210.8,15017.5,17157.8,15106.2,16696.1,16035.9,15418.9,13763.9,15595.2,15183.1,15515.9,14142.8,15012.7,16293.2,17771.4,15582.8,16049.9,16105.8,15623.6,14254.9,15266.8,16671,15665.4,13949.5,15146.9,15172.9,16981.4,16553.8,16438.5,15895.1,16989,13803.5,16678.3,17315.1,15895.4,14912.1) > 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/1aert1425512981.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/2n47f1425512981.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/3ox4r1425512981.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.679976063 0.561697098 0.595205796 0.597797189 [6] 0.488586904 0.479608406 0.380487454 0.409221887 0.283678820 [11] 0.181037176 0.259971466 0.396226899 0.171983607 0.042989158 [16] 0.053357920 0.088231550 0.011323553 -0.004297563 -0.047618530 [21] -0.012148775 -0.127265298 -0.180029365 -0.101457757 -0.007676131 [26] -0.142632195 -0.231526995 -0.206764655 -0.094174515 -0.133507990 [31] -0.112571865 -0.109703420 -0.079492344 -0.130731884 -0.158896713 [36] -0.115750851 -0.017479728 -0.115777165 -0.232151070 -0.187731052 [41] -0.114236293 -0.152139073 -0.128162167 -0.144088262 -0.128429331 [46] -0.162980889 -0.187376368 -0.164303808 -0.054004236 > (mypacf <- c(rpacf$acf)) [1] 0.679976063 0.184753790 0.304655904 0.181021028 -0.060336304 [6] 0.084950856 -0.190815966 0.146227922 -0.254373545 -0.126543183 [11] 0.235969814 0.318077938 -0.275886762 -0.320688577 -0.111595683 [16] 0.097709183 0.048098375 0.046518530 -0.032221177 0.015179621 [21] -0.075009107 0.004708246 -0.036197760 -0.055368115 0.014470747 [26] -0.017029124 0.033930821 0.165244708 0.008771355 0.072573210 [31] -0.127261773 -0.102215454 0.043018976 -0.071075822 -0.067785102 [36] -0.026979718 0.047865814 -0.090602188 0.029258521 -0.070056487 [41] -0.053486061 0.075648717 -0.036119511 0.041920277 -0.077276968 [46] 0.021910864 -0.028979537 0.005594158 > 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/4vy4f1425512981.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/53z141425512981.tab") > > try(system("convert tmp/1aert1425512981.ps tmp/1aert1425512981.png",intern=TRUE)) character(0) > try(system("convert tmp/2n47f1425512981.ps tmp/2n47f1425512981.png",intern=TRUE)) character(0) > try(system("convert tmp/3ox4r1425512981.ps tmp/3ox4r1425512981.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.189 0.212 1.414