R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 The R Foundation for Statistical Computing 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(812,100,113,213,149,134,228,138,162,291,182,2081,2752,125,144,274,257,186,327,209,213,375,400,1054,3377,101,120,221,222,167,297,185,189,298,237,1011,3013,110,109,215,176,134,202,139,169,262,214,1238,3748,127,160,138,134,163,172,163,193,226,344,1294,3524,141,186,135,161,131,170,146,160,151,151,1365) > 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/1mib91394717004.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/256c21394717004.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/3ttzi1394717004.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.290953908 -0.203043101 0.024946546 -0.014736289 [6] -0.025810568 0.043106016 -0.027647812 -0.010101735 0.024993797 [11] -0.207904574 -0.240481158 0.799563011 -0.187709718 -0.182593604 [16] 0.027962101 -0.016589211 -0.020896923 0.038350960 -0.026471235 [21] -0.003126056 0.023166245 -0.173562562 -0.174208982 0.589680116 [26] -0.129370801 -0.127921055 0.018236824 -0.016896072 -0.011135336 [31] 0.026748674 -0.022772646 0.003925825 0.013044918 -0.129586151 [36] -0.126803996 0.410823466 -0.055459509 -0.107039811 0.011827914 [41] -0.015616800 -0.005467257 0.017484750 -0.015630382 0.004415880 [46] 0.008282155 -0.096772779 -0.050761194 0.193278338 > (mypacf <- c(rpacf$acf)) [1] -0.2909539076 -0.3143044632 -0.1747386818 -0.1651203490 -0.1539811985 [6] -0.0812698971 -0.1060574154 -0.0911393142 -0.0595397615 -0.3313984154 [11] -0.7443616883 0.3234893255 0.1331950170 0.0549489098 0.0243516040 [16] -0.0043566588 -0.0148547714 -0.0428483310 -0.0572739530 -0.0614913488 [21] -0.0771473825 0.0294198627 0.1611991508 -0.0009757058 -0.0939843484 [26] 0.0005140579 -0.0167067803 -0.0217034305 -0.0017431688 -0.0129149824 [31] 0.0006113938 0.0253141385 0.0139455699 0.0296970604 -0.0135143153 [36] -0.0754954016 0.0830335263 0.0107562515 -0.0013509678 0.0060746016 [41] -0.0022303603 0.0033510456 0.0153148081 0.0004243827 0.0101352833 [46] -0.0094272931 0.1841564237 -0.1268482297 > 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/427wy1394717004.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/5lqe91394717005.tab") > > try(system("convert tmp/1mib91394717004.ps tmp/1mib91394717004.png",intern=TRUE)) character(0) > try(system("convert tmp/256c21394717004.ps tmp/256c21394717004.png",intern=TRUE)) character(0) > try(system("convert tmp/3ttzi1394717004.ps tmp/3ttzi1394717004.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.538 0.475 3.004