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(9.11,9.06,9.11,9.13,9.13,9.19,9.2,9.23,9.24,9.28,9.32,9.32,9.32,9.36,9.37,9.38,9.41,9.44,9.44,9.44,9.47,9.48,9.56,9.58,9.56,9.58,9.7,9.74,9.76,9.78,9.84,9.88,9.96,9.97,9.96,9.96,9.96,10.02,10.08,10.09,10.12,10.14,10.17,10.22,10.25,10.25,10.26,10.34,10.33,10.3,10.33,10.33,10.37,10.44,10.45,10.45,10.44,10.43,10.4,10.43,10.47,10.52,10.55,10.5,10.44,10.47,10.5,10.54,10.55,10.53,10.54,10.54,10.54,10.59,10.72,10.76,10.78,10.78,10.78,10.82,10.81,10.85) > 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/1lkzf1363717695.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/2ye611363717695.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/3ryip1363717695.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.0000000000 0.1440133457 -0.2112447581 -0.1507575974 -0.1317978216 [6] 0.0559714167 0.1934706627 0.1071763029 0.0162963598 0.0298562898 [11] -0.0858800860 -0.1826312899 0.0170090378 0.0802818332 0.0822278094 [16] 0.1691570717 -0.0723614246 -0.0570015460 -0.1073397903 -0.1806488069 [21] 0.0314197372 0.1740616935 0.0377116209 -0.0095838532 0.0281896708 [26] -0.1933579676 -0.2176398135 0.0692980201 -0.0003253875 -0.0480922767 [31] 0.0651505195 -0.0656282836 -0.1211520941 -0.0226945897 0.0248500836 [36] 0.0544381272 -0.0016428102 -0.0522381900 -0.0861197617 -0.0302610402 [41] -0.0241580399 -0.0669964985 -0.0157662162 -0.0085061062 0.0906799488 [46] 0.0736407531 -0.0877371758 0.0321054319 0.1479195832 > (mypacf <- c(rpacf$acf)) [1] 1.440133e-01 -2.368978e-01 -8.548292e-02 -1.553186e-01 5.127318e-02 [6] 1.149066e-01 6.440854e-02 5.937664e-02 1.093910e-01 -4.240531e-02 [11] -1.429056e-01 2.084931e-02 -2.187058e-02 2.282896e-02 1.412273e-01 [16] -6.512240e-02 1.105535e-01 -1.178122e-01 -1.610040e-01 -3.255299e-05 [21] 2.736617e-02 -6.744632e-02 4.655592e-02 1.103617e-01 -1.314899e-01 [26] -1.395763e-01 1.428977e-02 -1.424448e-01 -1.603556e-01 -3.052397e-02 [31] 5.231206e-03 -4.136384e-02 2.398168e-02 9.378027e-02 6.872692e-02 [36] -1.311520e-01 -8.656915e-02 -8.015024e-02 -7.142813e-02 -3.805561e-02 [41] -6.510888e-02 -8.379206e-03 2.592022e-02 4.383308e-02 3.334423e-03 [46] -1.124065e-02 8.107264e-02 9.629339e-02 > 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/41pnw1363717695.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/5iv5d1363717695.tab") > > try(system("convert tmp/1lkzf1363717695.ps tmp/1lkzf1363717695.png",intern=TRUE)) character(0) > try(system("convert tmp/2ye611363717695.ps tmp/2ye611363717695.png",intern=TRUE)) character(0) > try(system("convert tmp/3ryip1363717695.ps tmp/3ryip1363717695.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.686 0.248 1.924