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(7.66,7.53,7.54,7.56,7.57,7.56,7.57,7.61,7.61,7.6,7.61,7.61,7.62,7.7,7.73,7.75,7.76,7.76,7.77,7.79,7.79,7.79,7.83,7.83,7.88,7.95,8.01,8.05,8.1,8.1,8.16,8.18,8.2,7.99,8.01,8.02,8.03,8.04,8.07,8.08,8.08,8.1,8.11,8.15,8.16,8.17,8.18,8.15,8.15,8.17,8.16,8.15,8.16,8.15,8.18,8.19,8.18,8.2,8.21,8.22,8.23,8.25,8.28,8.28,8.29,8.3,8.34,8.38,8.39,8.44,8.46,8.46) > 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/19vi81363278815.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/2sq8b1363278815.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/309sg1363278815.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.046225542 0.034262773 -0.022467867 0.074109130 [6] -0.100854603 -0.039111233 -0.078991921 -0.107308638 -0.073497359 [11] -0.039048360 -0.011897700 0.002172636 0.035246996 0.051584777 [16] 0.048805160 0.001243502 0.053421088 0.028505538 -0.044083046 [21] -0.142832279 -0.109020999 -0.032440034 -0.034468560 -0.033095917 [26] -0.080147400 -0.131847145 -0.050986379 0.038051362 -0.112636536 [31] 0.018788258 -0.002102576 0.319858468 -0.092478429 -0.093118144 [36] 0.017545355 -0.041835361 -0.047888601 0.023916556 0.057316862 [41] -0.006088569 0.046471648 0.018920193 0.013122040 0.027702551 [46] 0.023038121 0.041770891 0.032954202 0.001122944 > (mypacf <- c(rpacf$acf)) [1] 0.0462255421 0.0321947660 -0.0255699965 0.0754609636 -0.1071937045 [6] -0.0346657111 -0.0663383007 -0.1116464168 -0.0471147517 -0.0388981665 [11] -0.0087189024 0.0025055620 0.0163840926 0.0321466469 0.0210387674 [16] -0.0263485996 0.0351850085 0.0144714369 -0.0523248379 -0.1309947094 [21] -0.1017005121 -0.0072726166 -0.0147897490 -0.0156105603 -0.0844198198 [26] -0.1643285469 -0.0852861649 -0.0157499990 -0.1815613843 -0.0263529737 [31] -0.0711600006 0.2868941456 -0.1408189221 -0.2024598599 0.0080208381 [36] -0.1668641607 -0.0121117605 0.0184879973 0.0278674534 0.0312853089 [41] -0.0157395583 -0.0382517257 -0.0350237635 -0.0275863999 -0.0552541580 [46] -0.0234042216 -0.0150720882 -0.0008273652 > 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/4bujy1363278815.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/5towy1363278815.tab") > > try(system("convert tmp/19vi81363278815.ps tmp/19vi81363278815.png",intern=TRUE)) character(0) > try(system("convert tmp/2sq8b1363278815.ps tmp/2sq8b1363278815.png",intern=TRUE)) character(0) > try(system("convert tmp/309sg1363278815.ps tmp/309sg1363278815.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.999 0.349 2.372