R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(435,431,434,439,455,452,426,428,433,438,442,446,442,436,444,454,469,471,443,437,444,451,457,460,454,439,441,446,459,456,433,424,430,428,424,419,409,397,397,401,413,413,390,385,397,398,406,412,409,404,412,418,434,431,406,416,424,427,438,444,442,443,453,471,476,476,461,462,460,463,467,468,465,459,465,471,472,472,456,455,456,462,463,461) > 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/1lam11352710830.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/2lkxz1352710830.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/38os41352710830.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.00000000 0.91181216 0.78674747 0.72283478 0.71567802 0.73521685 [7] 0.71627703 0.61837848 0.48380935 0.37593258 0.33157990 0.34880466 [13] 0.33162134 0.19100276 0.03021503 -0.06690357 -0.10669579 -0.11723019 [19] -0.15304853 -0.24844286 -0.37045221 -0.45650969 -0.47204609 -0.43062030 [25] -0.41108792 -0.48098882 -0.55707131 -0.56999713 -0.53575849 -0.47229425 [31] -0.42745859 -0.43447677 -0.45838636 -0.44628607 -0.38947720 -0.29682927 [37] -0.23538260 -0.24775407 -0.26443784 -0.23514963 -0.17725785 -0.09861036 [43] -0.04470214 -0.03663697 -0.04376472 -0.02598562 0.02439671 0.09120958 [49] 0.13000545 > (mypacf <- c(rpacf$acf)) [1] 0.911812156 -0.264853582 0.363385849 0.141204835 0.198011854 [6] -0.167366906 -0.308147624 -0.241043834 -0.173231452 0.035337077 [11] 0.279365669 -0.095612722 -0.534244313 0.053659622 0.004110627 [16] -0.071373574 -0.077957496 0.006296566 0.024664875 -0.052998172 [21] 0.032343502 0.010838773 -0.003193079 0.108906179 -0.022892812 [26] 0.089544546 0.041043182 -0.067356125 0.049764289 -0.035286872 [31] -0.001220619 0.074655191 0.041679335 -0.199121932 -0.045431261 [36] -0.130596769 -0.039942189 -0.093938279 -0.056566916 -0.048010734 [41] 0.058064922 -0.027944734 0.081338743 -0.049570363 0.006430264 [46] 0.049063312 -0.023460314 0.096739937 > 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/47io91352710830.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/5c5691352710831.tab") > > try(system("convert tmp/1lam11352710830.ps tmp/1lam11352710830.png",intern=TRUE)) character(0) > try(system("convert tmp/2lkxz1352710830.ps tmp/2lkxz1352710830.png",intern=TRUE)) character(0) > try(system("convert tmp/38os41352710830.ps tmp/38os41352710830.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.272 0.712 3.978