R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 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(163.93,164.28,164.58,165.97,166.3,166.27,166.27,166.44,166.26,166.64,166.07,166.19,166.19,166.19,166.35,166.52,167.17,167.16,167.16,167.16,167.39,168.46,168.55,168.58,168.58,169.21,169.29,169.24,169.53,169.57,169.57,169.67,170.04,170.39,170.57,170.48,170.48,170.48,170.49,170.72,171.11,171.07,171.07,171.07,171.05,172.28,172.74,172.86,172.86,173.24,173.2,173.38,172.89,172.98,172.98,172.69,172.77,172.65,172.3,172.17,172.17,173.07,173.27,173.05,173.41,173.37,173.37,173.08,173.97,175.23,174.9,174.83) > 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/1z0qy1363686555.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/2tfqa1363686555.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/3vkzn1363686555.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.076431603 -0.140668880 -0.088209273 0.046124296 [6] 0.063256713 -0.101715275 -0.010789922 0.068277885 -0.166862599 [11] -0.187519730 -0.095259019 0.065144025 0.010197058 -0.087403022 [16] -0.021121426 0.018541517 -0.004012180 0.074116795 0.038403847 [21] 0.009581058 -0.045268389 0.004755640 0.087627032 0.216470671 [26] -0.026439948 -0.095472826 -0.116479942 0.044263779 0.148354112 [31] 0.031788803 -0.050816464 -0.075807027 -0.050472723 -0.109473735 [36] -0.076611451 0.078463910 -0.031189330 -0.092894853 -0.087041161 [41] 0.071081966 -0.002799728 0.087194526 0.082636725 0.081140293 [46] 0.013983647 -0.009845263 0.082491631 0.158332956 > (mypacf <- c(rpacf$acf)) [1] 0.076431603 -0.147371583 -0.066431851 0.039413063 0.035954599 [6] -0.107583229 0.026800804 0.048334367 -0.204978303 -0.147650860 [11] -0.103010798 -0.013400799 -0.052108471 -0.062351298 -0.030796840 [16] -0.039010249 -0.037295943 0.065936795 -0.023628506 -0.065906562 [21] -0.063359818 -0.001360186 0.032116320 0.207243171 -0.042802041 [26] -0.054380939 -0.095170662 0.048113726 0.144622262 0.053635364 [31] -0.033267037 -0.062590496 0.021233229 -0.068898514 -0.032542362 [36] 0.002199445 -0.134359700 -0.059315624 -0.010958542 0.087641677 [41] -0.116586118 0.056326010 0.040721732 0.048375352 0.045623630 [46] 0.001074451 -0.002300980 0.049221788 > 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/4zbcq1363686555.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/5t2831363686555.tab") > > try(system("convert tmp/1z0qy1363686555.ps tmp/1z0qy1363686555.png",intern=TRUE)) character(0) > try(system("convert tmp/2tfqa1363686555.ps tmp/2tfqa1363686555.png",intern=TRUE)) character(0) > try(system("convert tmp/3vkzn1363686555.ps tmp/3vkzn1363686555.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.083 0.336 2.415