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(19,14,15,7,12,12,14,9,8,4,7,3,5,0,-2,6,11,9,17,21,21,41,57,65,68,73,71,71,70,69,65,57,57,57,55,65,65,64,60,43,47,40,31,27,24,23,17,16,15,8,5,6,5,12,8,17,22,24,36,31,34,47,33,35,31,35,39,46,40,50,62,57,62,57) > 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/1brhs1369225112.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/2b4ot1369225112.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/3bkar1369225112.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.949635643 0.887665203 0.810015095 0.703222191 [6] 0.606559675 0.505594484 0.395328213 0.294332007 0.193988181 [11] 0.099137595 0.005971355 -0.090631951 -0.194335655 -0.291762982 [16] -0.385408198 -0.471063086 -0.535607448 -0.591289174 -0.628208377 [21] -0.646583575 -0.656320999 -0.642210792 -0.608447077 -0.568878204 [26] -0.513353345 -0.456483548 -0.394731301 -0.315014472 -0.228934209 [31] -0.141941108 -0.058176776 0.021644378 0.087516732 0.148057619 [36] 0.199919142 0.236171839 0.261110279 0.276816014 0.288682894 [41] 0.297719272 0.300881766 0.306767618 0.304850644 0.291045628 [46] 0.275070595 0.249106506 0.216048713 0.181353099 > (mypacf <- c(rpacf$acf)) [1] 0.9496356435 -0.1440303846 -0.1828156860 -0.3260370111 0.1140143341 [6] -0.0542323862 -0.1309747039 -0.0442617900 -0.0299387350 -0.0003701183 [11] -0.1531287966 -0.1477647562 -0.2180943882 -0.0110276649 -0.0680228738 [16] -0.0521213895 0.0278773486 -0.0657593713 0.0298152937 -0.0548461999 [21] -0.0596163601 0.0559817654 0.1102749666 -0.0296976810 0.0029027106 [26] -0.0761696540 0.0367695418 0.1369347518 0.0570235195 -0.0490927713 [31] -0.1340475168 0.0411477891 -0.1178812452 -0.0530591605 -0.0956196962 [36] -0.0456362625 -0.0750777496 -0.0130282579 0.0429684766 -0.0388851791 [41] 0.0042687514 0.0584355057 0.0346988882 -0.0644618419 0.0482486383 [46] 0.0294654457 0.0306299261 -0.0042849363 > 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/4fkqx1369225112.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/5mj9e1369225112.tab") > > try(system("convert tmp/1brhs1369225112.ps tmp/1brhs1369225112.png",intern=TRUE)) character(0) > try(system("convert tmp/2b4ot1369225112.ps tmp/2b4ot1369225112.png",intern=TRUE)) character(0) > try(system("convert tmp/3bkar1369225112.ps tmp/3bkar1369225112.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.284 0.402 2.666