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(23.9,24.06,24.33,24.39,24.39,24.49,24.83,25.08,25.11,25.13,25.17,25.11,25.35,25.36,25.35,25.34,25.39,25.58,25.71,25.66,25.74,25.73,25.72,25.55,25.71,25.92,25.93,26,26.02,26.08,26.17,26.18,26.21,26.28,26.34,26.17,26.38,26.36,26.27,26.26,26.49,26.99,27.14,27.1,27.01,26.93,26.97,26.35,26.93,26.92,27.05,27.01,26.9,26.93,26.95,26.89,26.7,26.55,26.48,25.71,26.17,26.31,26.58,26.49,26.57,26.6,26.69,26.59,26.75,26.79,26.8,26.62) > 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/fisher/rcomp/tmp/14nt91354820407.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/2je2z1354820407.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/30oe51354820407.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.124499817 0.071634638 -0.145949389 0.042709476 [6] -0.014100918 -0.087482082 0.045100905 0.107249172 -0.054302152 [11] 0.018411349 -0.217926416 0.490803024 -0.141004422 0.059544412 [16] -0.071893940 0.039122616 -0.121882176 -0.116693821 -0.002164296 [21] 0.108259394 0.033125431 -0.047648659 -0.062737804 0.272433260 [26] -0.066249223 -0.020212596 -0.056754969 0.057955681 -0.044848707 [31] -0.051717230 -0.028363791 -0.009749596 0.012056388 0.018068753 [36] 0.001116765 0.173162739 -0.052350216 -0.001664907 -0.030214116 [41] -0.008198048 -0.072732553 -0.004685109 0.022192883 0.023931451 [46] -0.067564250 -0.024368748 -0.061480820 0.083110604 > (mypacf <- c(rpacf$acf)) [1] -1.244998e-01 5.701823e-02 -1.329265e-01 7.433040e-03 7.195299e-03 [6] -1.139494e-01 3.220482e-02 1.303189e-01 -6.683705e-02 1.137130e-02 [11] -1.890774e-01 4.618985e-01 -6.765109e-02 -4.521129e-02 7.027307e-02 [16] -2.071254e-02 -1.728736e-01 -3.687703e-02 -1.982192e-02 -3.624184e-06 [21] 6.719822e-02 -1.224645e-01 1.469669e-01 5.622014e-02 3.746681e-02 [26] -3.545221e-02 -1.181329e-02 -2.636121e-02 7.024568e-02 6.376494e-03 [31] -4.657052e-02 -1.041682e-01 -7.033506e-02 1.614043e-01 -3.404863e-02 [36] 1.998964e-02 -7.422599e-03 6.651660e-02 6.145195e-03 -3.092959e-02 [41] -6.566905e-02 6.726583e-02 2.283623e-03 -2.190241e-02 -7.281684e-02 [46] -7.689238e-02 -2.429337e-02 -6.788675e-02 > 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/4ih5r1354820407.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/5pht21354820407.tab") > > try(system("convert tmp/14nt91354820407.ps tmp/14nt91354820407.png",intern=TRUE)) character(0) > try(system("convert tmp/2je2z1354820407.ps tmp/2je2z1354820407.png",intern=TRUE)) character(0) > try(system("convert tmp/30oe51354820407.ps tmp/30oe51354820407.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.993 0.566 2.547