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(49.98,50.12,50.37,50.39,50.34,50.32,50.32,50.32,50.67,50.86,50.95,51.02,51.02,51.06,50.9,51.23,51.29,51.3,51.3,51.3,51.46,51.47,51.77,51.82,51.82,51.84,51.9,51.94,52.22,52.27,52.27,52.28,52.53,52.73,52.72,52.67,52.67,52.65,52.69,52.73,52.84,52.83,52.83,52.84,52.82,53.09,53.4,53.43,53.43,53.42,53.6,53.69,54.05,54.04,54.04,54.08,54.05,54.39,54.38,54.46,54.46,54.69,54.91,55.52,56.01,56.07,56.07,56.09,56.29,56.45,56.87,56.87) > 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/1pipt1353324873.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/268pk1353324873.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/3wt321353324873.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.943474849 0.884697562 0.833582712 0.784585616 [6] 0.736747442 0.685902540 0.630887042 0.572273531 0.525135968 [11] 0.489521878 0.457647016 0.427997254 0.395592812 0.362013856 [16] 0.324795344 0.296829515 0.267971319 0.237282747 0.203069643 [21] 0.166829695 0.137067875 0.108342934 0.085510017 0.061272346 [26] 0.034261343 0.006174883 -0.016376028 -0.034072313 -0.049192533 [31] -0.064623256 -0.082573802 -0.102737343 -0.119145972 -0.132818904 [36] -0.146447936 -0.162949358 -0.180972679 -0.202502020 -0.224792546 [41] -0.243912614 -0.258226806 -0.274064499 -0.292208357 -0.310494042 [46] -0.325862117 -0.337663505 -0.345523970 -0.353440016 > (mypacf <- c(rpacf$acf)) [1] 0.943474849 -0.049585541 0.039120045 -0.011527279 -0.013235287 [6] -0.053391169 -0.065263895 -0.068211393 0.064707575 0.065070113 [11] 0.017556446 0.011977428 -0.037328676 -0.032195433 -0.072280213 [16] 0.041910634 -0.041871261 -0.016952365 -0.043849618 -0.030432112 [21] 0.028714241 -0.026709180 0.021139834 -0.031949500 -0.033531278 [26] -0.040357848 0.017640704 -0.001182799 0.009238497 -0.020908690 [31] -0.021371293 -0.036854748 0.001428174 -0.014985517 -0.027994673 [36] -0.029780692 -0.030815014 -0.044807171 -0.044339328 -0.015436629 [41] 0.007906729 -0.031291959 -0.033874587 -0.029735772 -0.012304885 [46] -0.015815400 -0.006116783 -0.024626620 > 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/4grel1353324873.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/57d1w1353324873.tab") > > try(system("convert tmp/1pipt1353324873.ps tmp/1pipt1353324873.png",intern=TRUE)) character(0) > try(system("convert tmp/268pk1353324873.ps tmp/268pk1353324873.png",intern=TRUE)) character(0) > try(system("convert tmp/3wt321353324873.ps tmp/3wt321353324873.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.942 0.482 3.405