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(99.7,107.5,107.5,114.5,118.7,117.8,111.7,112.3,104.9,102.4,100.3,106.6,94.2,96.9,94.7,104.9,108.3,104.7,108.3,105.2,99.2,99.3,92.3,98.6,88.4,89.5,90.5,103.5,105.1,107.1,111.6,104.6,103.3,104.6,94.1,97.7,92.4,89.5,100.1,109.6,105.5,108.9,108.8,103.9,104.3,102.1,96.6,101.4,90.4,91.8,100.4,105.3,105.1,107.6,103.7,102.7,99.2,95.6,96.3,104.1) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > par2 <- '1' > par1 <- '60' > #'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/17jez1394996841.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/21zqb1394996841.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/3estg1394996841.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.1304759752 0.0951486851 -0.0094426856 -0.1486218888 [6] -0.2309941073 -0.0346232651 -0.3069582943 0.0303168946 -0.0429094605 [11] 0.0188249073 0.0097749667 0.5998466084 -0.1761390972 0.2061215490 [16] -0.0726926536 -0.1297275111 -0.0617349702 -0.1418327337 -0.2403491315 [21] 0.1059985863 -0.1610337928 0.1031925133 0.0945647215 0.2728316601 [26] -0.0628483579 0.1352324726 -0.1119041593 0.0296461637 -0.0471003345 [31] -0.1488584039 -0.0588358935 0.0681885931 -0.1688879879 0.1168987297 [36] 0.0272594232 0.1499848266 0.0206524695 0.0409720142 -0.0850538576 [41] 0.0587397373 -0.0767223443 -0.0437528379 -0.0162144301 0.0149700311 [46] -0.0806506994 0.0587247004 -0.0485377113 0.0783062947 0.0488260542 [51] 0.0183566600 -0.0350330505 0.0003336485 -0.0635641871 -0.0205543006 [56] 0.0047390223 0.0134067331 0.0022759622 0.0319194940 > (mypacf <- c(rpacf$acf)) [1] -0.130475975 0.079477732 0.012649058 -0.159553733 -0.281576389 [6] -0.087884022 -0.319724033 -0.131016676 -0.159865771 -0.176652875 [11] -0.261623739 0.476748615 -0.119127322 0.018827607 -0.084814700 [16] -0.016287063 0.087914840 -0.140361575 -0.040624107 -0.056311787 [21] -0.127764279 0.024721920 0.013446926 -0.133458356 -0.039401290 [26] -0.174195295 -0.038569547 0.055818672 -0.070232428 -0.033814108 [31] 0.020968799 0.038669829 0.026870043 -0.109171506 -0.017195859 [36] 0.031778082 -0.008484430 0.044022756 -0.086890230 -0.088103603 [41] 0.031308627 0.065331162 -0.015320932 -0.031679011 -0.025692582 [46] 0.008310716 -0.031383441 -0.081158902 0.080694573 0.007106456 [51] -0.019966294 -0.090043841 -0.053710111 -0.090522767 0.008461817 [56] -0.029842711 0.019892743 -0.019454002 > 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/4ej2x1394996841.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/5lo7y1394996841.tab") > > try(system("convert tmp/17jez1394996841.ps tmp/17jez1394996841.png",intern=TRUE)) character(0) > try(system("convert tmp/21zqb1394996841.ps tmp/21zqb1394996841.png",intern=TRUE)) character(0) > try(system("convert tmp/3estg1394996841.ps tmp/3estg1394996841.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.365 0.406 2.769