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(39.28,39.36,39.55,39.64,39.8,39.79,39.79,39.86,39.91,40,40.01,40.01,40.01,39.96,40,39.76,39.68,39.7,39.7,39.73,39.64,39.56,39.67,39.66,39.66,40.05,39.99,40.06,40.08,40.1,40.1,40.12,40.07,40.24,40.58,40.72,40.72,40.89,40.9,41.04,41.27,41.29,41.29,41.33,41.34,41.37,41.33,41.37,41.37,41.42,41.61,41.58,41.75,41.75,41.75,41.85,41.84,41.97,42.01,42.04,42.04,42.06,41.93,41.93,41.99,42.03,42.03,42.12,42.22,42.21,42.23,42.22) > 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/fisher/rcomp/tmp/1rgfj1354447914.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/fisher/rcomp/tmp/2ne5z1354447914.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/fisher/rcomp/tmp/3tj071354447914.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.96179470 0.92257708 0.88547396 0.84686531 0.81340947 [7] 0.77935754 0.74288850 0.70803142 0.67408819 0.64015566 0.60272521 [13] 0.56521309 0.52661335 0.48740603 0.45006149 0.40663110 0.35917055 [19] 0.31305985 0.26531771 0.21949099 0.17483498 0.12635816 0.08431478 [25] 0.04133537 -0.00242069 -0.03807994 -0.07667061 -0.11478999 -0.15280619 [31] -0.18950848 -0.22907554 -0.26989397 -0.30906753 -0.34403775 -0.37188365 [37] -0.39330453 -0.41599780 -0.43098751 -0.43937406 -0.44151584 -0.43962403 [43] -0.43744378 -0.43557750 -0.43337869 -0.43018040 -0.42529918 -0.42340839 [49] -0.41278329 > (mypacf <- c(rpacf$acf)) [1] 0.9617946997 -0.0329811457 0.0080160927 -0.0405509636 0.0493695722 [6] -0.0297960767 -0.0470251184 -0.0016607364 -0.0054580661 -0.0195049626 [11] -0.0718736969 -0.0200858604 -0.0389090493 -0.0322303259 -0.0087373829 [16] -0.1075531591 -0.0811336113 -0.0239349420 -0.0560222250 -0.0211716606 [21] -0.0313008089 -0.0830656902 0.0442090250 -0.0599772645 -0.0469563271 [26] 0.0642788115 -0.0674954496 -0.0259807416 -0.0485631383 -0.0130369272 [31] -0.0859930118 -0.0572562365 -0.0374465231 0.0140634714 0.0421429950 [36] 0.0254358376 -0.0365836592 0.0656324138 0.0560762074 0.0832330896 [41] 0.0169209188 0.0017385880 0.0060665017 -0.0202858897 0.0001021481 [46] 0.0005415197 -0.0638975688 0.1201940668 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4gsyn1354447914.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/fisher/rcomp/tmp/5bm7g1354447914.tab") > > try(system("convert tmp/1rgfj1354447914.ps tmp/1rgfj1354447914.png",intern=TRUE)) character(0) > try(system("convert tmp/2ne5z1354447914.ps tmp/2ne5z1354447914.png",intern=TRUE)) character(0) > try(system("convert tmp/3tj071354447914.ps tmp/3tj071354447914.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.751 0.521 2.253